diff options
| author | Dan Carpenter <error27@gmail.com> | 2010-11-12 00:04:43 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-11-16 15:25:52 -0500 |
| commit | ebba26f4a8d0c137a2d365b6bded2a0d7fcd1d06 (patch) | |
| tree | 4ceaf840194b8e375c978b57274f83cf29db0c06 | |
| parent | 5fb5d38fc268b8285125b213b9b2ded9322a371c (diff) | |
Staging: quickstart: free after input_unregister_device()
input_unregister_device() releases "quickstart_input" so the
input_free_device() is a double free. Also I noticed that there is a
memory leak if the call to input_register_device() fails.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/staging/quickstart/quickstart.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c index d746715d3d89..d83bec876d2e 100644 --- a/drivers/staging/quickstart/quickstart.c +++ b/drivers/staging/quickstart/quickstart.c | |||
| @@ -355,7 +355,6 @@ static int quickstart_acpi_remove(struct acpi_device *device, int type) | |||
| 355 | static void quickstart_exit(void) | 355 | static void quickstart_exit(void) |
| 356 | { | 356 | { |
| 357 | input_unregister_device(quickstart_input); | 357 | input_unregister_device(quickstart_input); |
| 358 | input_free_device(quickstart_input); | ||
| 359 | 358 | ||
| 360 | device_remove_file(&pf_device->dev, &dev_attr_pressed_button); | 359 | device_remove_file(&pf_device->dev, &dev_attr_pressed_button); |
| 361 | device_remove_file(&pf_device->dev, &dev_attr_buttons); | 360 | device_remove_file(&pf_device->dev, &dev_attr_buttons); |
| @@ -375,6 +374,7 @@ static int __init quickstart_init_input(void) | |||
| 375 | { | 374 | { |
| 376 | struct quickstart_btn **ptr = &quickstart_data.btn_lst; | 375 | struct quickstart_btn **ptr = &quickstart_data.btn_lst; |
| 377 | int count; | 376 | int count; |
| 377 | int ret; | ||
| 378 | 378 | ||
| 379 | quickstart_input = input_allocate_device(); | 379 | quickstart_input = input_allocate_device(); |
| 380 | 380 | ||
| @@ -391,7 +391,13 @@ static int __init quickstart_init_input(void) | |||
| 391 | ptr = &((*ptr)->next); | 391 | ptr = &((*ptr)->next); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | return input_register_device(quickstart_input); | 394 | ret = input_register_device(quickstart_input); |
| 395 | if (ret) { | ||
| 396 | input_free_device(quickstart_input); | ||
| 397 | return ret; | ||
| 398 | } | ||
| 399 | |||
| 400 | return 0; | ||
| 395 | } | 401 | } |
| 396 | 402 | ||
| 397 | static int __init quickstart_init(void) | 403 | static int __init quickstart_init(void) |
