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; } - /* Get the debug Device */ kp->dbg_dev = &pdev->dev; kp->input = input; - kp->n_rows = pdata->rows; kp->n_cols = pdata->cols; kp->irq = platform_get_irq(pdev, 0); @@ -424,6 +428,7 @@ err2: input = NULL; err1: input_free_device(input); +err0: kfree(kp); return error; } -- 1.7.0.4 -- 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