From: Vimal Singh <vimal.newwork@gmail.com>
To: Manjunatha GK <manjugk@ti.com>
Cc: linux-omap@vger.kernel.org, Damodar <x0132156@ti.com>,
Tony Lindgren <tony@atomide.com>
Subject: Re: [PATCH] OMAP2/3: Keypad: Fix memory leak
Date: Thu, 20 May 2010 20:41:11 +0530 [thread overview]
Message-ID: <AANLkTiludDGO8EW_siAzxqo2bC6SNmtnMTV932D1Wumv@mail.gmail.com> (raw)
In-Reply-To: <1274365792-24938-1-git-send-email-manjugk@ti.com>
On Thu, May 20, 2010 at 7:59 PM, Manjunatha GK <manjugk@ti.com> wrote:
> From: Damodar <x0132156@ti.com>
>
> This patch corrects Possible memory leak of 'input' allocated
> through input_allocate_device and Suspicious dereference of pointer 'pdata'
> before NULL check
>
> Signed-off-by: Damodar Santhapuri <x0132156@ti.com>
> Signed-off-by: Manjunatha GK <manjugk@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
>
> ---
> drivers/input/keyboard/twl4030_keypad.c | 21 +++++++++++++--------
> 1 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
> index 7aa59e0..aa13aec 100644
> --- a/drivers/input/keyboard/twl4030_keypad.c
> +++ b/drivers/input/keyboard/twl4030_keypad.c
> @@ -326,30 +326,34 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
> */
> static int __devinit twl4030_kp_probe(struct platform_device *pdev)
> {
> - struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
> - const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
> + struct twl4030_keypad_data *pdata;
> + const struct matrix_keymap_data *keymap_data;
> struct twl4030_keypad *kp;
> struct input_dev *input;
> u8 reg;
> int error;
> -
> + if (!pdev) {
> + printk(KERN_ERR "Invalid platorm_device\n");
> + return -EINVAL;
> + }
> + pdata = pdev->dev.platform_data;
> if (!pdata || !pdata->rows || !pdata->cols ||
> pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
> dev_err(&pdev->dev, "Invalid platform_data\n");
> return -EINVAL;
> }
> -
> + keymap_data = pdata->keymap_data;
> kp = kzalloc(sizeof(*kp), GFP_KERNEL);
> + if (!kp)
> + return -ENOMEM;
> input = input_allocate_device();
> - if (!kp || !input) {
> + if (!input) {
> error = -ENOMEM;
> - goto err1;
> + goto err0;
If I am not mistaking you should still goto 'err1', as
'input_register_device' is yet not called.
--
Regards,
Vimal Singh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-05-20 15:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 14:29 [PATCH] OMAP2/3: Keypad: Fix memory leak Manjunatha GK
2010-05-20 14:29 ` [PATCH] OMAP: McSPI: Fix Null pointer check Manjunatha GK
2010-05-20 14:29 ` [PATCH] OMAP: FB: " Manjunatha GK
2010-05-20 14:29 ` [PATCH] OMAP: Fix Memory leak Manjunatha GK
2010-05-20 14:58 ` Vimal Singh
2010-05-20 15:11 ` Vimal Singh [this message]
2010-05-20 15:16 ` [PATCH] OMAP2/3: Keypad: Fix memory leak Vimal Singh
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=AANLkTiludDGO8EW_siAzxqo2bC6SNmtnMTV932D1Wumv@mail.gmail.com \
--to=vimal.newwork@gmail.com \
--cc=linux-omap@vger.kernel.org \
--cc=manjugk@ti.com \
--cc=tony@atomide.com \
--cc=x0132156@ti.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).