diff mbox

[1/9] pinctrl: pinctrl-nomadik: Fix possible memory leak

Message ID 1341493572-29735-2-git-send-email-lee.jones@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Lee Jones July 5, 2012, 1:06 p.m. UTC
If the Nomadik Pin Control driver is continuously bound and unbound
from the same device a number of times the kzalloc() will leak
memory. Replacing it with devm_kzalloc() will ensure memory is
freed automatically in the event of failure and unbinding.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/pinctrl/pinctrl-nomadik.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Linus Walleij July 6, 2012, 7:03 a.m. UTC | #1
On Thu, Jul 5, 2012 at 3:06 PM, Lee Jones <lee.jones@linaro.org> wrote:

> If the Nomadik Pin Control driver is continuously bound and unbound
> from the same device a number of times the kzalloc() will leak
> memory. Replacing it with devm_kzalloc() will ensure memory is
> freed automatically in the event of failure and unbinding.
>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>

A patch like this but more all-encompassing was already sent out
by me some days ago:
http://marc.info/?l=linux-kernel&m=134139303405730&w=2

Please test that one and see if it solves your problem.

Yours,
Linus Walleij
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 3e7e47d..af0389f 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -1194,7 +1194,7 @@  static int __devinit nmk_gpio_probe(struct platform_device *dev)
 	}
 
 	if (np) {
-		pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+		pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL);
 		if (!pdata)
 			return -ENOMEM;