diff --git a/[refs] b/[refs] index fe0a0e157f2f..83f7e29d46dc 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 97c146ef075dc40ae34407c03d3860fc3850b8e8 +refs/heads/master: 09f82ea92822a7bbb7e816508abbda47ed54a77f diff --git a/trunk/lib/kobject.c b/trunk/lib/kobject.c index 1015f74212d0..493e991abb1b 100644 --- a/trunk/lib/kobject.c +++ b/trunk/lib/kobject.c @@ -149,12 +149,16 @@ void kobject_init(struct kobject * kobj) static void unlink(struct kobject * kobj) { + struct kobject *parent = kobj->parent; + if (kobj->kset) { spin_lock(&kobj->kset->list_lock); list_del_init(&kobj->entry); spin_unlock(&kobj->kset->list_lock); } + kobj->parent = NULL; kobject_put(kobj); + kobject_put(parent); } /** @@ -208,7 +212,6 @@ int kobject_add(struct kobject * kobj) if (error) { /* unlink does the kobject_put() for us */ unlink(kobj); - kobject_put(parent); /* be noisy on error issues */ if (error == -EEXIST) @@ -590,7 +593,6 @@ static void kobject_cleanup(struct kobject *kobj) { struct kobj_type * t = get_ktype(kobj); struct kset * s = kobj->kset; - struct kobject * parent = kobj->parent; const char *name = kobj->k_name; pr_debug("kobject: '%s' (%p): %s\n", @@ -604,7 +606,6 @@ static void kobject_cleanup(struct kobject *kobj) } if (s) kset_put(s); - kobject_put(parent); } static void kobject_release(struct kref *kref)