projects/linux·commit 7da6844c

[PATCH] cdev: cdev_put oops

7da6844c · Brian King <[email protected]> · 2005-07-12 13:58:30 -07:00

While fixing an oops in the st driver in a dirty release path, I
encountered an oops in cdev_put for cdevs allocated using cdev_alloc.  If
cdev_del is called when the cdev kobject still has an open user, when the
last cdev_put is called, the cdev_put will call kobject_put, which will end
up ultimately releasing the cdev in cdev_dynamic_release.  Patch fixes the
oops by preventing cdev_put from accessing freed memory.

Signed-off-by: Brian King <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
7da6844cf7bc44dcda548a0a0aebf85f3a1c1485
Parents
50a52234

Changes

1 files changed · +2 −1

FileStatusAddDelContent
fs/char_dev.cmodified+2−1View file

fs/char_dev.c

View file
diff --git a/fs/char_dev.c b/fs/char_dev.c
index a69a5d8..3b1b1ee 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -277,8 +277,9 @@ static struct kobject *cdev_get(struct cdev *p)
void cdev_put(struct cdev *p)
{
if (p) {
+ struct module *owner = p->owner;
kobject_put(&p->kobj);
- module_put(p->owner);
+ module_put(owner);
}
}