tree 9105032fd6803f2e0d6a24a483145f39ef5fdecd
parent 50a5223428bbe77bc0f312100c950b6f4520ba34
author Brian King <[EMAIL PROTECTED]> Wed, 13 Jul 2005 03:58:30 -0700
committer Linus Torvalds <[EMAIL PROTECTED]> Wed, 13 Jul 2005 06:01:02 -0700

[PATCH] cdev: cdev_put oops

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]>

 fs/char_dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/char_dev.c b/fs/char_dev.c
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -277,8 +277,9 @@ static struct kobject *cdev_get(struct c
 void cdev_put(struct cdev *p)
 {
        if (p) {
+               struct module *owner = p->owner;
                kobject_put(&p->kobj);
-               module_put(p->owner);
+               module_put(owner);
        }
 }
 
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to