From: Wei Yongjun <weiyj.lk@gmail.com> To: tony@atomide.com, linux@arm.linux.org.uk, paul@pwsan.com Cc: yongjun_wei@trendmicro.com.cn, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] gpio/omap: fix possible memory leak in omap2_gpio_dev_init() Date: Mon, 3 Sep 2012 20:42:27 +0800 [thread overview] Message-ID: <CAPgLHd-XS_AtLr+8R6yNkSXdNxO3i-NapK7o5zBUado-7R99=w@mail.gmail.com> (raw) From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> 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> --- arch/arm/mach-omap2/gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c index 9ad7d48..fe626e90 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; }
WARNING: multiple messages have this Message-ID (diff)
From: weiyj.lk@gmail.com (Wei Yongjun) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] gpio/omap: fix possible memory leak in omap2_gpio_dev_init() Date: Mon, 3 Sep 2012 20:42:27 +0800 [thread overview] Message-ID: <CAPgLHd-XS_AtLr+8R6yNkSXdNxO3i-NapK7o5zBUado-7R99=w@mail.gmail.com> (raw) From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> 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> --- arch/arm/mach-omap2/gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c index 9ad7d48..fe626e90 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; }
next reply other threads:[~2012-09-03 12:42 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-09-03 12:42 Wei Yongjun [this message] 2012-09-03 12:42 ` [PATCH v2] gpio/omap: fix possible memory leak in omap2_gpio_dev_init() Wei Yongjun 2012-09-07 22:06 ` Kevin Hilman 2012-09-07 22:06 ` Kevin Hilman 2012-09-07 22:24 ` Tony Lindgren 2012-09-07 22:24 ` Tony Lindgren 2012-09-07 22:37 ` Kevin Hilman 2012-09-07 22:37 ` Kevin Hilman
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='CAPgLHd-XS_AtLr+8R6yNkSXdNxO3i-NapK7o5zBUado-7R99=w@mail.gmail.com' \ --to=weiyj.lk@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-omap@vger.kernel.org \ --cc=linux@arm.linux.org.uk \ --cc=paul@pwsan.com \ --cc=tony@atomide.com \ --cc=yongjun_wei@trendmicro.com.cn \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.