list_del_init(&kobj->entry);
up_write(&kobj->kset->subsys->rwsem);
}
- if (kobj->parent)
- kobject_put(kobj->parent);
kobject_put(kobj);
}
kobj->parent = parent;
error = create_dir(kobj);
- if (error)
+ if (error) {
unlink(kobj);
- else {
+ if (parent)
+ kobject_put(parent);
+ } else {
/* If this kobj does not belong to a kset,
try to find a parent that does. */
top_kobj = kobj;
{
struct kobj_type * t = get_ktype(kobj);
struct kset * s = kobj->kset;
+ struct kobject * parent = kobj->parent;
pr_debug("kobject %s: cleaning up\n",kobject_name(kobj));
if (kobj->k_name != kobj->name)
t->release(kobj);
if (s)
kset_put(s);
+ if (parent)
+ kobject_put(parent);
}
/**