linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Chris Ball <cjb@laptop.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vipin Bhandari <vipin.bhandari@ti.com>,
	David Brownell <dbrownell@users.sourceforge.net>,
	linux-mmc@vger.kernel.org
Subject: [PATCH 1/4] [ARM] davinci_mmc: fix a memory leak
Date: Mon, 22 Nov 2010 16:44:27 +0800	[thread overview]
Message-ID: <1290415467.5471.7.camel@mola> (raw)
In-Reply-To: <1290415359.5471.4.camel@mola>

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.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/mmc/host/davinci_mmc.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index e15547c..7c7d268 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -1297,7 +1297,7 @@ cpu_freq_fail:
 		mmc_free_host(mmc);
 
 	if (mem)
-		release_resource(mem);
+		release_mem_region(mem->start, resource_size(mem));
 
 	dev_dbg(&pdev->dev, "probe err %d\n", ret);
 
@@ -1322,7 +1322,8 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev)
 
 		iounmap(host->base);
 
-		release_resource(host->mem_res);
+		release_mem_region(host->mem_res->start,
+					resource_size(host->mem_res));
 
 		mmc_free_host(host->mmc);
 	}
-- 
1.7.2




  reply	other threads:[~2010-11-22  8:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-22  8:42 [PATCH 0/4] fix a memory leak related to request_mem_region/release_mem_region usage Axel Lin
2010-11-22  8:44 ` Axel Lin [this message]
2010-11-22  8:45   ` [PATCH 2/4] [ARM] mvsdio: fix a memory leak Axel Lin
2010-11-22  8:46     ` [PATCH 3/4] [ARM] pxamci: " Axel Lin
2010-11-22  8:47       ` [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call Axel Lin
2010-11-25  9:03         ` Sascha Hauer
2010-12-05  2:51           ` Chris Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1290415467.5471.7.camel@mola \
    --to=axel.lin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cjb@laptop.org \
    --cc=dbrownell@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=vipin.bhandari@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).