Skip to content

Commit

Permalink
[PATCH] cdev: cdev_put oops
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Brian King authored and Linus Torvalds committed Jul 12, 2005
1 parent 50a5223 commit 7da6844
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/char_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 7da6844

Please sign in to comment.