Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1cba532 authored by Dan Carpenter's avatar Dan Carpenter Committed by Dmitry Torokhov
Browse files

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: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 0fffed27
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -436,7 +436,6 @@ void adxl34x_resume(struct adxl34x *ac)

	mutex_unlock(&ac->mutex);
}

EXPORT_SYMBOL_GPL(adxl34x_resume);

static ssize_t adxl34x_disable_show(struct device *dev,
@@ -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;
@@ -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);