From: Dan Carpenter <dan.carpenter@oracle.com>
To: Anders Roxell <anders.roxell@linaro.org>
Cc: erico.nunes@datacom.ind.br, wsa@the-dreams.de,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: BUG: KASAN: i2c dev use after free
Date: Mon, 4 Mar 2019 18:37:14 +0300 [thread overview]
Message-ID: <20190304153714.GD13452@kadam> (raw)
In-Reply-To: <CADYN=9KkjPSP4KJ+AzG=Njq49zJ5fbWNZ4V_jOvHkq_kt0biyA@mail.gmail.com>
I wasn't trying to fix anything so complicated as this, it was a
more obvious use after free. It does feel intuitively that we should
call device_destroy() before the cdev_del() so that it's in the reverse
order from how it was allocated but I don't see any reason to think
that will make a difference.
---
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 3f7b9af11137..7e85e2cf26c1 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -687,9 +687,9 @@ static int i2cdev_detach_adapter(struct device *dev, void *dummy)
if (!i2c_dev) /* attach_adapter must have failed */
return 0;
+ device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
cdev_del(&i2c_dev->cdev);
put_i2c_dev(i2c_dev);
- device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
return 0;
--
2.17.1
next prev parent reply other threads:[~2019-03-04 15:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 14:11 BUG: KASAN: i2c dev use after free Anders Roxell
2019-03-04 15:37 ` Dan Carpenter [this message]
2019-03-06 17:28 ` Anders Roxell
2020-03-22 16:18 ` Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190304153714.GD13452@kadam \
--to=dan.carpenter@oracle.com \
--cc=anders.roxell@linaro.org \
--cc=erico.nunes@datacom.ind.br \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.