Commit 7da6844c authored by Brian King's avatar Brian King Committed by Linus Torvalds

[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: default avatarBrian King <>
Cc: <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 50a52234
...@@ -277,8 +277,9 @@ static struct kobject *cdev_get(struct cdev *p) ...@@ -277,8 +277,9 @@ static struct kobject *cdev_get(struct cdev *p)
void cdev_put(struct cdev *p) void cdev_put(struct cdev *p)
{ {
if (p) { if (p) {
struct module *owner = p->owner;
kobject_put(&p->kobj); kobject_put(&p->kobj);
module_put(p->owner); module_put(owner);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment