Skip to content

Commit

Permalink
Input: adxl34x - fix leak and use after free
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Dmitry Torokhov committed Jul 23, 2010
1 parent 0fffed2 commit f1cba53
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/input/misc/adxl34x.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,10 @@ void adxl34x_resume(struct adxl34x *ac)
if (ac->suspended && !ac->disabled && ac->opened)
__adxl34x_enable(ac);

ac->suspended= false;
ac->suspended = false;

mutex_unlock(&ac->mutex);
}

EXPORT_SYMBOL_GPL(adxl34x_resume);

static ssize_t adxl34x_disable_show(struct device *dev,
Expand Down Expand Up @@ -709,7 +708,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
input_dev = input_allocate_device();
if (!ac || !input_dev) {
err = -ENOMEM;
goto err_out;
goto err_free_mem;
}

ac->fifo_delay = fifo_delay_default;
Expand Down Expand Up @@ -904,9 +903,9 @@ int adxl34x_remove(struct adxl34x *ac)
sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group);
free_irq(ac->irq, ac);
input_unregister_device(ac->input);
dev_dbg(ac->dev, "unregistered accelerometer\n");
kfree(ac);

dev_dbg(ac->dev, "unregistered accelerometer\n");
return 0;
}
EXPORT_SYMBOL_GPL(adxl34x_remove);
Expand Down

0 comments on commit f1cba53

Please sign in to comment.