* [patch] Staging: quickstart: free after input_unregister_device()
@ 2010-11-12 5:04 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2010-11-12 5:04 UTC (permalink / raw)
To: kernel-janitors
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>
diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c
index d746715..d83bec8 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)
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);
@@ -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();
@@ -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)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-11-12 5:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-12 5:04 [patch] Staging: quickstart: free after input_unregister_device() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox