kobject_init should not be grabing any references, but only initializing
the object. This patch fixes this, and makes the lock hold-time shorter
for when a kset is present in the kobject.
The current kernel tree has been audited to verify that this change
should be safe.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
return;
kref_init(&kobj->kref);
INIT_LIST_HEAD(&kobj->entry);
- kobj->kset = kset_get(kobj->kset);
}
kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>" );
if (kobj->kset) {
- spin_lock(&kobj->kset->list_lock);
+ kobj->kset = kset_get(kobj->kset);
if (!parent) {
parent = kobject_get(&kobj->kset->kobj);
kobject_get(parent);
}
- list_add_tail(&kobj->entry,&kobj->kset->list);
+ spin_lock(&kobj->kset->list_lock);
+ list_add_tail(&kobj->entry, &kobj->kset->list);
spin_unlock(&kobj->kset->list_lock);
kobj->parent = parent;
}