Skip to content

Commit

Permalink
Staging: quickstart: free after input_unregister_device()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
error27 authored and gregkh committed Nov 16, 2010
1 parent 5fb5d38 commit ebba26f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/staging/quickstart/quickstart.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ static int quickstart_acpi_remove(struct acpi_device *device, int type)
static void quickstart_exit(void)
{
input_unregister_device(quickstart_input);
input_free_device(quickstart_input);

device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
device_remove_file(&pf_device->dev, &dev_attr_buttons);
Expand All @@ -375,6 +374,7 @@ static int __init quickstart_init_input(void)
{
struct quickstart_btn **ptr = &quickstart_data.btn_lst;
int count;
int ret;

quickstart_input = input_allocate_device();

Expand All @@ -391,7 +391,13 @@ static int __init quickstart_init_input(void)
ptr = &((*ptr)->next);
}

return input_register_device(quickstart_input);
ret = input_register_device(quickstart_input);
if (ret) {
input_free_device(quickstart_input);
return ret;
}

return 0;
}

static int __init quickstart_init(void)
Expand Down

0 comments on commit ebba26f

Please sign in to comment.