Skip to contentSkip to conversation

fix a memory leak related to request_mem_region/release_mem_region usage

PATCH Applied Axel Lin 3 participants 7 messages Nov 22, 2010 – Dec 5, 2010

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

cover fix a memory leak related to request_mem_region/release_mem_region usage

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(-)
Signature · 1 line
1.7.2
author
#1 lore raw

PATCH 1/4 davinci_mmc: fix a memory leak

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.

---
 drivers/mmc/host/davinci_mmc.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/davinci_mmc.c +3 -2
index e15547c..7c7d268 100644
@@ -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);
 	}
Signature · 1 line
1.7.2
author
#2 lore raw

PATCH 2/4 mvsdio: fix a memory leak

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.

---
 drivers/mmc/host/mvsdio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/mvsdio.c +2 -2
index a5bf60e..6a29972 100644
@@ -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);
Signature · 1 line
1.7.2
author
#3 lore raw

PATCH 3/4 pxamci: fix a memory leak

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.

---
 drivers/mmc/host/pxamci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/pxamci.c +2 -2
index 7257738..d98e647 100644
@@ -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);
 	}
Signature · 1 line
1.7.2
author
#4 lore raw

PATCH 4/4 mxcmmc: remove a unnecessary release_resource() call

Remove release_resource() after release_mem_region().

---
 drivers/mmc/host/mxcmmc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/mmc/host/mxcmmc.c +0 -1
index 2b9f7c8..4428594 100644
@@ -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);
 
Signature · 1 line
1.7.2
maintainer Acked-by on v1 4/4
#5 lore raw

Re: [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call

Quoted 3 lines · Axel Lin

Remove release_resource() after release_mem_region().

Quoted 22 lines
---
 drivers/mmc/host/mxcmmc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/mmc/host/mxcmmc.c +0 -1
index 2b9f7c8..4428594 100644
@@ -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);
 
Signature · 1 line
1.7.2
Signature · 4 lines
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 |
Applied
#6 lore raw

Re: [PATCH 4/4] [ARM] mxcmmc: remove a unnecessary release_resource() call

Hi,

Quoted 18 lines · Sascha Hauer
Quoted 3 lines · Axel Lin

Remove release_resource() after release_mem_region().

Quoted 11 lines
---
 drivers/mmc/host/mxcmmc.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/mmc/host/mxcmmc.c +0 -0
index 2b9f7c8..4428594 100644
@@ -967,7 +967,6 @@ static int mxcmci_remove(struct platform_device *pdev)
 	clk_put(host->clk);
 
Quoted 5 lines

drivers/mmc/host/mxcmmc.c static int mxcmci_remove(struct platform_device *pdev) · line 972

Quoted 5 lines
drivers/mmc/host/mxcmmc.c +0 -1
 	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.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child