Re: [PATCH 1/2] input: keypad: tc3589x: localize platform data

From: Linus Walleij
Date: Tue Apr 07 2015 - 09:07:42 EST


On Fri, Mar 27, 2015 at 5:47 PM, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> wrote:

> Hmm, just noticed an issue:
>
>> >
>> > keypad = kzalloc(sizeof(struct tc_keypad), GFP_KERNEL);
>> > + keypad->board = tc3589x_keypad_of_probe(&pdev->dev);
>> > + if (IS_ERR(keypad->board)) {
>> > + dev_err(&pdev->dev, "invalid keypad platform data\n");
>> > + return PTR_ERR(keypad->board);
>> > + }
>> > +
>> > input = input_allocate_device();
>> > if (!keypad || !input) {
>> > dev_err(&pdev->dev, "failed to allocate keypad memory\n");
>
> You slid of prasing right in between memory allocation and checking if
> it succeeded, so there is a potential oops and memory leak now.
>
> I want to commit the version of the patch below, holler if you disagree.
> Note that I reverted much of plat -> board renames to keep the patch
> small.

Sorry. The new version looks fine. Reviewed-by.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/