aboutsummaryrefslogtreecommitdiffstats
path: root/fs/char_dev.c
diff options
context:
space:
mode:
authorBrian King <brking@us.ibm.com>2005-07-12 16:58:30 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 19:01:02 -0400
commit7da6844cf7bc44dcda548a0a0aebf85f3a1c1485 (patch)
tree9105032fd6803f2e0d6a24a483145f39ef5fdecd /fs/char_dev.c
parent50a5223428bbe77bc0f312100c950b6f4520ba34 (diff)
[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 <brking@us.ibm.com> Cc: <viro@parcelfarce.linux.theplanet.co.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/char_dev.c')
-rw-r--r--fs/char_dev.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c
index a69a5d8a406f..3b1b1eefdbb0 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -277,8 +277,9 @@ static struct kobject *cdev_get(struct cdev *p)
277void cdev_put(struct cdev *p) 277void cdev_put(struct cdev *p)
278{ 278{
279 if (p) { 279 if (p) {
280 struct module *owner = p->owner;
280 kobject_put(&p->kobj); 281 kobject_put(&p->kobj);
281 module_put(p->owner); 282 module_put(owner);
282 } 283 }
283} 284}
284 285