summaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/da9052_onkey.c
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-04-12 05:55:18 +0200
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-04-12 07:15:04 +0200
commit0e3d0f3d960bf5b895adcf9ffc79d2077f1411d5 (patch)
treeaf1258e22b8ded4e7d4d0f123b06335c9c7cb1d4 /drivers/input/misc/da9052_onkey.c
parentInput: gpio_mouse - use linux/gpio.h rather than asm/gpio.h (diff)
downloadlinux-0e3d0f3d960bf5b895adcf9ffc79d2077f1411d5.tar.xz
linux-0e3d0f3d960bf5b895adcf9ffc79d2077f1411d5.zip
Input: da9052 - fix memory leak in da9052_onkey_probe()
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>
Diffstat (limited to 'drivers/input/misc/da9052_onkey.c')
-rw-r--r--drivers/input/misc/da9052_onkey.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 34aebb8cd080..3c843cd725fa 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -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;