From 52bad11636415eb28d2ca8276354dcdd0b44e3f2 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 21 Oct 2012 17:57:19 -0700 Subject: [PATCH] --- yaml --- r: 334677 b: refs/heads/master c: 2f0157f13f42800aa3d9017ebb0fb80a65f7b2de h: refs/heads/master i: 334675: 6aa9745cdf4586b7b27c437eef916e051eca2a0f v: v3 --- [refs] | 2 +- trunk/fs/char_dev.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 74d78b7b7df7..fe982b41abd1 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 6f0c0580b70c89094b3422ba81118c7b959c7556 +refs/heads/master: 2f0157f13f42800aa3d9017ebb0fb80a65f7b2de diff --git a/trunk/fs/char_dev.c b/trunk/fs/char_dev.c index 3f152b92a94a..afc2bb691780 100644 --- a/trunk/fs/char_dev.c +++ b/trunk/fs/char_dev.c @@ -471,9 +471,19 @@ static int exact_lock(dev_t dev, void *data) */ int cdev_add(struct cdev *p, dev_t dev, unsigned count) { + int error; + p->dev = dev; p->count = count; - return kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p); + + error = kobj_map(cdev_map, dev, count, NULL, + exact_match, exact_lock, p); + if (error) + return error; + + kobject_get(p->kobj.parent); + + return 0; } static void cdev_unmap(dev_t dev, unsigned count) @@ -498,14 +508,20 @@ void cdev_del(struct cdev *p) static void cdev_default_release(struct kobject *kobj) { struct cdev *p = container_of(kobj, struct cdev, kobj); + struct kobject *parent = kobj->parent; + cdev_purge(p); + kobject_put(parent); } static void cdev_dynamic_release(struct kobject *kobj) { struct cdev *p = container_of(kobj, struct cdev, kobj); + struct kobject *parent = kobj->parent; + cdev_purge(p); kfree(p); + kobject_put(parent); } static struct kobj_type ktype_cdev_default = {