On Thu, May 20, 2010 at 8:41 PM, Vimal Singh <vimal.newwork@xxxxxxxxx> wrote: > On Thu, May 20, 2010 at 7:59 PM, Manjunatha GK <manjugk@xxxxxx> wrote: >> From: Damodar <x0132156@xxxxxx> >> >> 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@xxxxxx> >> Signed-off-by: Manjunatha GK <manjugk@xxxxxx> >> Cc: Tony Lindgren <tony@xxxxxxxxxxx> >> >> --- >> 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. Sorry, my ignorance that device is yet not allocated. -- Regards, Vimal Singh -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html