diff options
author | Dan Carpenter <error27@gmail.com> | 2010-07-23 02:38:45 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-07-23 02:39:16 -0400 |
commit | f1cba532e8c1001a39650379aa7e04ad974d0592 (patch) | |
tree | 9c663e053d1a9c35d260de1b00a141e6b9dd073f | |
parent | 0fffed27f92d9d7a34de9fe017b7082b5958bb93 (diff) |
Input: adxl34x - fix leak and use after free
These are a couple smatch issues. In the original code, if only one of
the allocation fails we leak the other variable so we should goto
out_free_mem.
Also there was a use after free if debugging was enabled and so I moved
the kfree() down a line.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r-- | drivers/input/misc/adxl34x.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c index bb9c10f9dfd3..e2ca01708080 100644 --- a/drivers/input/misc/adxl34x.c +++ b/drivers/input/misc/adxl34x.c | |||
@@ -432,11 +432,10 @@ void adxl34x_resume(struct adxl34x *ac) | |||
432 | if (ac->suspended && !ac->disabled && ac->opened) | 432 | if (ac->suspended && !ac->disabled && ac->opened) |
433 | __adxl34x_enable(ac); | 433 | __adxl34x_enable(ac); |
434 | 434 | ||
435 | ac->suspended= false; | 435 | ac->suspended = false; |
436 | 436 | ||
437 | mutex_unlock(&ac->mutex); | 437 | mutex_unlock(&ac->mutex); |
438 | } | 438 | } |
439 | |||
440 | EXPORT_SYMBOL_GPL(adxl34x_resume); | 439 | EXPORT_SYMBOL_GPL(adxl34x_resume); |
441 | 440 | ||
442 | static ssize_t adxl34x_disable_show(struct device *dev, | 441 | static ssize_t adxl34x_disable_show(struct device *dev, |
@@ -709,7 +708,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq, | |||
709 | input_dev = input_allocate_device(); | 708 | input_dev = input_allocate_device(); |
710 | if (!ac || !input_dev) { | 709 | if (!ac || !input_dev) { |
711 | err = -ENOMEM; | 710 | err = -ENOMEM; |
712 | goto err_out; | 711 | goto err_free_mem; |
713 | } | 712 | } |
714 | 713 | ||
715 | ac->fifo_delay = fifo_delay_default; | 714 | ac->fifo_delay = fifo_delay_default; |
@@ -904,9 +903,9 @@ int adxl34x_remove(struct adxl34x *ac) | |||
904 | sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group); | 903 | sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group); |
905 | free_irq(ac->irq, ac); | 904 | free_irq(ac->irq, ac); |
906 | input_unregister_device(ac->input); | 905 | input_unregister_device(ac->input); |
906 | dev_dbg(ac->dev, "unregistered accelerometer\n"); | ||
907 | kfree(ac); | 907 | kfree(ac); |
908 | 908 | ||
909 | dev_dbg(ac->dev, "unregistered accelerometer\n"); | ||
910 | return 0; | 909 | return 0; |
911 | } | 910 | } |
912 | EXPORT_SYMBOL_GPL(adxl34x_remove); | 911 | EXPORT_SYMBOL_GPL(adxl34x_remove); |