summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2003-11-07 02:58:26 -0800
committerLinus Torvalds <torvalds@home.osdl.org>2003-11-07 02:58:26 -0800
commit59ccfc460a322aa9522a259572258a5fffbd4bcc (patch)
treed0077e793d0b6b09f98be3f94bf9bb34dcd8f986
parent6077b1d358b09e4fb02ac9d5a3bed4884f7afe86 (diff)
[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.
-rw-r--r--drivers/base/class.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index e9327c8ec04d..4858ba62428c 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -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;