linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] fix a memory leak related to request_mem_region/release_mem_region usage
@ 2010-11-22  8:42 Axel Lin
  2010-11-22  8:44 ` [PATCH 1/4] [ARM] davinci_mmc: fix a memory leak Axel Lin
  0 siblings, 1 reply; 7+ messages in thread
From: Axel Lin @ 2010-11-22  8:42 UTC (permalink / raw)
  To: linux-kernel
  Cc: Chris Ball, Andrew Morton, linux-mmc, Vipin Bhandari,
	David Brownell, Nicolas Pitre, Eric Miao

This serial of patches fixes a memory leak related to request_mem_region
and release_mem_region usage.

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.


Axel Lin (4):
  [ARM] davinci_mmc: fix a memory leak
  [ARM] mvsdio: fix a memory leak
  [ARM] pxamci: fix a memory leak
  [ARM] mxcmmc: remove a unnecessary release_resource() call

 drivers/mmc/host/davinci_mmc.c |    5 +++--
 drivers/mmc/host/mvsdio.c      |    4 ++--
 drivers/mmc/host/mxcmmc.c      |    1 -
 drivers/mmc/host/pxamci.c      |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

-- 
1.7.2




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] [ARM] davinci_mmc: fix a memory leak
  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
  2010-11-22  8:45   ` [PATCH 2/4] [ARM] mvsdio: " Axel Lin
  0 siblings, 1 reply; 7+ messages in thread
From: Axel Lin @ 2010-11-22  8:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Chris Ball, Andrew Morton, Vipin Bhandari, David Brownell, linux-mmc

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




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] [ARM] mvsdio: fix a memory leak
  2010-11-22  8:44 ` [PATCH 1/4] [ARM] davinci_mmc: fix a memory leak Axel Lin
@ 2010-11-22  8:45   ` Axel Lin
  2010-11-22  8:46     ` [PATCH 3/4] [ARM] pxamci: " Axel Lin
  0 siblings, 1 reply; 7+ messages in thread
From: Axel Lin @ 2010-11-22  8:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Nicolas Pitre, Chris Ball, linux-mmc

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/mvsdio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index a5bf60e..6a29972 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -825,7 +825,7 @@ out:
 			iounmap(host->base);
 	}
 	if (r)
-		release_resource(r);
+		release_mem_region(r->start, SZ_1K);
 	if (mmc)
 		mmc_free_host(mmc);
 
@@ -850,7 +850,7 @@ static int __exit mvsd_remove(struct platform_device *pdev)
 		del_timer_sync(&host->timer);
 		mvsd_power_down(host);
 		iounmap(host->base);
-		release_resource(host->res);
+		release_mem_region(host->res->start, SZ_1K);
 		mmc_free_host(mmc);
 	}
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.2




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] [ARM] pxamci: fix a memory leak
  2010-11-22  8:45   ` [PATCH 2/4] [ARM] mvsdio: " Axel Lin
@ 2010-11-22  8:46     ` Axel Lin
  2010-11-22  8:47       ` [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call Axel Lin
  0 siblings, 1 reply; 7+ messages in thread
From: Axel Lin @ 2010-11-22  8:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: Chris Ball, Andrew Morton, Eric Miao, linux-mmc

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/pxamci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 7257738..d98e647 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -774,7 +774,7 @@ err_gpio_ro:
 	}
 	if (mmc)
 		mmc_free_host(mmc);
-	release_resource(r);
+	release_mem_region(r->start, SZ_4K);
 	return ret;
 }
 
@@ -824,7 +824,7 @@ static int pxamci_remove(struct platform_device *pdev)
 
 		clk_put(host->clk);
 
-		release_resource(host->res);
+		release_mem_region(host->res->start, SZ_4K);
 
 		mmc_free_host(mmc);
 	}
-- 
1.7.2




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call
  2010-11-22  8:46     ` [PATCH 3/4] [ARM] pxamci: " Axel Lin
@ 2010-11-22  8:47       ` Axel Lin
  2010-11-25  9:03         ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Axel Lin @ 2010-11-22  8:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Chris Ball, Sascha Hauer, Andrew Morton, linux-mmc

Remove release_resource() after release_mem_region().

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

diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index 2b9f7c8..4428594 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -967,7 +967,6 @@ static int mxcmci_remove(struct platform_device *pdev)
 	clk_put(host->clk);
 
 	release_mem_region(host->res->start, resource_size(host->res));
-	release_resource(host->res);
 
 	mmc_free_host(mmc);
 
-- 
1.7.2




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Sascha Hauer @ 2010-11-25  9:03 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Chris Ball, Andrew Morton, linux-mmc

On Mon, Nov 22, 2010 at 04:47:51PM +0800, Axel Lin wrote:
> Remove release_resource() after release_mem_region().
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Acked-by: Sascha Hauer <s.hauer@pengutronix.de>

> ---
>  drivers/mmc/host/mxcmmc.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> index 2b9f7c8..4428594 100644
> --- a/drivers/mmc/host/mxcmmc.c
> +++ b/drivers/mmc/host/mxcmmc.c
> @@ -967,7 +967,6 @@ static int mxcmci_remove(struct platform_device *pdev)
>  	clk_put(host->clk);
>  
>  	release_mem_region(host->res->start, resource_size(host->res));
> -	release_resource(host->res);
>  
>  	mmc_free_host(mmc);
>  
> -- 
> 1.7.2
> 
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call
  2010-11-25  9:03         ` Sascha Hauer
@ 2010-12-05  2:51           ` Chris Ball
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Ball @ 2010-12-05  2:51 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Axel Lin, linux-kernel, Chris Ball, Andrew Morton, linux-mmc

Hi,

On Thu, Nov 25, 2010 at 10:03:11AM +0100, Sascha Hauer wrote:
> On Mon, Nov 22, 2010 at 04:47:51PM +0800, Axel Lin wrote:
> > Remove release_resource() after release_mem_region().
> > 
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> 
> Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
> 
> > ---
> >  drivers/mmc/host/mxcmmc.c |    1 -
> >  1 files changed, 0 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> > index 2b9f7c8..4428594 100644
> > --- a/drivers/mmc/host/mxcmmc.c
> > +++ b/drivers/mmc/host/mxcmmc.c
> > @@ -967,7 +967,6 @@ static int mxcmci_remove(struct platform_device *pdev)
> >  	clk_put(host->clk);
> >  
> >  	release_mem_region(host->res->start, resource_size(host->res));
> > -	release_resource(host->res);
> >  
> >  	mmc_free_host(mmc);
> >  

Pushed to mmc-next for .38, thanks.

-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-12-05  2:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/4] [ARM] davinci_mmc: fix a memory leak Axel Lin
2010-11-22  8:45   ` [PATCH 2/4] [ARM] mvsdio: " 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

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).