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

Commit 43da13ff authored by Dan Carpenter's avatar Dan Carpenter Committed by TARKZiM
Browse files

i2c: dev: use after free in detach



commit e6be18f6d62c1d3b331ae020b76a29c2ccf6b0bf upstream.

The call to put_i2c_dev() frees "i2c_dev" so there is a use after
free when we call cdev_del(&i2c_dev->cdev).

Fixes: d6760b14d4a1 ('i2c: dev: switch from register_chrdev to cdev API')
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Change-Id: I47b170677624022ad6f4e9811e0040abd5772a78
parent 0919771b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -602,9 +602,9 @@ static int i2cdev_detach_adapter(struct device *dev, void *dummy)
	if (!i2c_dev) /* attach_adapter must have failed */
		return 0;

	cdev_del(&i2c_dev->cdev);
	put_i2c_dev(i2c_dev);
	device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
	cdev_del(&i2c_dev->cdev);

	pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
	return 0;