[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200526183914.507467866@linuxfoundation.org>
Date: Tue, 26 May 2020 20:52:41 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Dan Carpenter <dan.carpenter@...cle.com>,
Wolfram Sang <wsa@...-dreams.de>,
Ben Hutchings <ben.hutchings@...ethink.co.uk>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 4.4 22/65] i2c: dev: use after free in detach
From: Dan Carpenter <dan.carpenter@...cle.com>
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: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Wolfram Sang <wsa@...-dreams.de>
Signed-off-by: Ben Hutchings <ben.hutchings@...ethink.co.uk>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/i2c/i2c-dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 382c66d5a470..e5cd307ebfc9 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -599,9 +599,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;
--
2.25.1
Powered by blists - more mailing lists