From patchwork Wed Nov 10 02:37:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 70607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qy0-f184.google.com (mail-qy0-f184.google.com [209.85.216.184]) by ozlabs.org (Postfix) with ESMTP id 29398B713A for ; Wed, 10 Nov 2010 13:33:35 +1100 (EST) Received: by qyk38 with SMTP id 38sf176284qyk.11 for ; Tue, 09 Nov 2010 18:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:received:received:subject:from:to:cc :date:message-id:mime-version:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=tVkU60aqTTFfa6vm1gCL4GBV9ZZ/otTMseOCCZMQAcg=; b=MSrarocnrtIAGSPfUXqGePdbCzgR6GYz0YoN2cqqEnjoBhJg5T+hu7xrQFclwQV7ia KGiUfCJH8NeNyWDA509Nf5oxPlka3j/xXbF47Orq8CAhKaextTyAzUfOgvCn+CWBT4zF 5K8AJ8BMa2SgdXaKNDQz7Rn82xIKoY6aQzyhI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:subject:from:to:cc:date:message-id :mime-version:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=hIctUkopmy+NtT1TwLS6MxBp8D2s8FmMAF3IvtEwXunvUnEjThciXnbwSU58FcgkMD +vLyqlClDh+o/Ol1vNCmv7xUNJH8CJF+bUA9ky22BjZW7z/0tpVVNjA/4fAcj/OSyhfq ka68B6t230tVcC/vSIYvV4d/FRgwEYFNpZEzg= Received: by 10.229.2.34 with SMTP id 34mr664631qch.29.1289356412467; Tue, 09 Nov 2010 18:33:32 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.229.80.196 with SMTP id u4ls83174qck.0.p; Tue, 09 Nov 2010 18:33:31 -0800 (PST) Received: by 10.229.182.67 with SMTP id cb3mr950342qcb.27.1289356411777; Tue, 09 Nov 2010 18:33:31 -0800 (PST) Received: by 10.229.182.67 with SMTP id cb3mr950340qcb.27.1289356411714; Tue, 09 Nov 2010 18:33:31 -0800 (PST) Received: from mail-qw0-f45.google.com (mail-qw0-f45.google.com [209.85.216.45]) by gmr-mx.google.com with ESMTP id u1si67860qco.9.2010.11.09.18.33.30; Tue, 09 Nov 2010 18:33:30 -0800 (PST) Received-SPF: pass (google.com: domain of axel.lin@gmail.com designates 209.85.216.45 as permitted sender) client-ip=209.85.216.45; Received: by qwf6 with SMTP id 6so180557qwf.18 for ; Tue, 09 Nov 2010 18:33:30 -0800 (PST) Received: by 10.224.189.130 with SMTP id de2mr5590758qab.78.1289356410539; Tue, 09 Nov 2010 18:33:30 -0800 (PST) Received: from [192.168.100.50] (60-251-136-127.HINET-IP.hinet.net [60.251.136.127]) by mx.google.com with ESMTPS id l14sm78386vcr.42.2010.11.09.18.33.26 (version=SSLv3 cipher=RC4-MD5); Tue, 09 Nov 2010 18:33:29 -0800 (PST) Subject: [rtc-linux] [PATCH] rtc: rtc-omap - fix a memory leak From: Axel Lin To: linux-kernel Cc: "Mark A. Greer" , Alessandro Zummo , rtc-linux@googlegroups.com, Andrew Morton Date: Wed, 10 Nov 2010 10:37:20 +0800 Message-Id: <1289356640.13311.1.camel@mola> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Original-Sender: axel.lin@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of axel.lin@gmail.com designates 209.85.216.45 as permitted sender) smtp.mail=axel.lin@gmail.com; dkim=pass (test mode) header.i=@gmail.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , request_mem_region() will call kzalloc to allocate memory for struct resource. release_resource() unregisters the resource but does not free the allocated memory, thus use release_mem_region() instead to fix the memory leak. Also add a missing iounmap() in omap_rtc_remove(). Signed-off-by: Axel Lin Acked-by: Mark A. Greer --- drivers/rtc/rtc-omap.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 73377b0..e72b523 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -429,13 +429,14 @@ fail1: fail0: iounmap(rtc_base); fail: - release_resource(mem); + release_mem_region(mem->start, resource_size(mem)); return -EIO; } static int __exit omap_rtc_remove(struct platform_device *pdev) { struct rtc_device *rtc = platform_get_drvdata(pdev); + struct resource *mem = dev_get_drvdata(&rtc->dev); device_init_wakeup(&pdev->dev, 0); @@ -447,8 +448,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) if (omap_rtc_timer != omap_rtc_alarm) free_irq(omap_rtc_alarm, rtc); - release_resource(dev_get_drvdata(&rtc->dev)); rtc_device_unregister(rtc); + iounmap(rtc_base); + release_mem_region(mem->start, resource_size(mem)); return 0; }