Commit 59ccfc46 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Linus Torvalds

[PATCH] fix reference count bug with class devices

When a kobject is associated with a kset, the kset MUST be set before
the kobject is initialized (by either a call to kobject_register() or
kobject_init()).  This patch fixes the class code which improperly set
the kset after the kobject was initialized, which would cause improper
reference counts on the kset.

Thanks to Mike Anderson for locating the source of this bug.
parent 6077b1d3
......@@ -255,6 +255,7 @@ static decl_subsys(class_obj, &ktype_class_device, &class_hotplug_ops);
void class_device_initialize(struct class_device *class_dev)
{
kobj_set_kset_s(class_dev, class_obj_subsys);
kobject_init(&class_dev->kobj);
INIT_LIST_HEAD(&class_dev->node);
}
......@@ -277,7 +278,6 @@ int class_device_add(struct class_device *class_dev)
/* first, register with generic layer. */
kobject_set_name(&class_dev->kobj, class_dev->class_id);
kobj_set_kset_s(class_dev, class_obj_subsys);
if (parent)
class_dev->kobj.parent = &parent->subsys.kset.kobj;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment