summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWei Yongjun2012-09-03 14:42:27 +0200
committerTony Lindgren2012-09-10 20:48:30 +0200
commit5e40b1c1cc5ae9b949f96d40356afd2a31477365 (patch)
tree987c47aba51e8736855c54e48a05b77db8cdd5b9 /arch
parentLinux 3.6-rc5 (diff)
downloadkernel-qcow2-linux-5e40b1c1cc5ae9b949f96d40356afd2a31477365.tar.gz
kernel-qcow2-linux-5e40b1c1cc5ae9b949f96d40356afd2a31477365.tar.xz
kernel-qcow2-linux-5e40b1c1cc5ae9b949f96d40356afd2a31477365.zip
gpio/omap: fix possible memory leak in omap2_gpio_dev_init()
pdata and pdata->regs have been allocated in this function and should be freed before leaving it, and in the other error handling cases too. spatch with a semantic match is used to found this problem. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Acked-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/gpio.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 9ad7d489b0de..fe626e903dea 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -60,6 +60,7 @@ static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
if (!pdata->regs) {
pr_err("gpio%d: Memory allocation failed\n", id);
+ kfree(pdata);
return -ENOMEM;
}
@@ -121,6 +122,7 @@ static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
break;
default:
WARN(1, "Invalid gpio bank_type\n");
+ kfree(pdata->regs);
kfree(pdata);
return -EINVAL;
}