From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
To: linux-kernel@vger.kernel.org
Cc: Greg KH <greg@kroah.com>
Subject: [PATCH] drivers-core: nullify private pointer on device-release
Date: Thu, 1 Oct 2009 10:02:08 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.64.0910010950330.4408@axis700.grange> (raw)
Device structures can be reused over multiple device_add / device_release
cycles. As the private pointer in that struct is checked for NULL, it has
to be nullified after freeing the private data. Failure to do so causes a
use after free bug.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6bee6af..3c9f449 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -122,6 +122,7 @@ static void device_release(struct kobject *kobj)
WARN(1, KERN_ERR "Device '%s' does not have a release() "
"function, it is broken and must be fixed.\n",
dev_name(dev));
+ dev->p = NULL;
kfree(p);
}
next reply other threads:[~2009-10-01 8:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-01 8:02 Guennadi Liakhovetski [this message]
2009-10-01 13:27 ` Greg KH
2009-10-01 13:45 ` Guennadi Liakhovetski
2009-10-01 14:15 ` Greg KH
2009-10-01 14:28 ` Kay Sievers
2009-10-05 8:11 ` Guennadi Liakhovetski
2009-10-05 16:03 ` Greg KH
2009-10-05 16:14 ` Guennadi Liakhovetski
2009-10-05 16:30 ` Greg KH
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=Pine.LNX.4.64.0910010950330.4408@axis700.grange \
--to=g.liakhovetski@gmx.de \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®