Skip to content

Commit

Permalink
Input: da9052 - fix memory leak in da9052_onkey_probe()
Browse files Browse the repository at this point in the history
If, in drivers/input/misc/da9052_onkey.c::da9052_onkey_probe(), the
call to either kzalloc() or input_allocate_device() fails then we will
return -ENOMEM from the function without freeing the other allocation
that may have succeeded, thus we leak either the memory allocated for
'onkey' or the memory allocated for 'input_dev' if one succeeds and
the other fails.
Fix that by jumping to the 'err_free_mem' label at the end of the
function that properly cleans up rather than returning directly.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Jesper Juhl authored and Dmitry Torokhov committed Apr 12, 2012
1 parent 55158c8 commit 0e3d0f3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/input/misc/da9052_onkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ static int __devinit da9052_onkey_probe(struct platform_device *pdev)
input_dev = input_allocate_device();
if (!onkey || !input_dev) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
return -ENOMEM;
error = -ENOMEM;
goto err_free_mem;
}

onkey->input = input_dev;
Expand Down

0 comments on commit 0e3d0f3

Please sign in to comment.