Skip to content

Commit

Permalink
sysdev: fix problem with sysdev_class being re-registered
Browse files Browse the repository at this point in the history
We need to initialize the kobject for a sysdev_class as it could have
been recycled (stupid static kobjects...)

We also do the same thing in case sysdev devices are being
re-registered.

Thanks to Balaji Rao <balajirrao@gmail.com> for pointing out the
problem.

Signed-off-by: Balaji Rao <balajirrao@gmail.com>
Tested-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Mar 10, 2008
1 parent cdeeeae commit ef79df2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/base/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ int sysdev_class_register(struct sysdev_class * cls)
pr_debug("Registering sysdev class '%s'\n",
kobject_name(&cls->kset.kobj));
INIT_LIST_HEAD(&cls->drivers);
memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
cls->kset.kobj.parent = &system_kset->kobj;
cls->kset.kobj.ktype = &ktype_sysdev_class;
cls->kset.kobj.kset = system_kset;
Expand Down Expand Up @@ -227,6 +228,9 @@ int sysdev_register(struct sys_device * sysdev)

pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));

/* initialize the kobject to 0, in case it had previously been used */
memset(&sysdev->kobj, 0x00, sizeof(struct kobject));

/* Make sure the kset is set */
sysdev->kobj.kset = &cls->kset;

Expand Down

0 comments on commit ef79df2

Please sign in to comment.