]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sysdev: fix problem with sysdev_class being re-registered
authorGreg Kroah-Hartman <gregkh@suse.de>
Sat, 8 Mar 2008 22:07:16 +0000 (03:37 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 10 Mar 2008 23:33:32 +0000 (16:33 -0700)
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>
drivers/base/sys.c

index 2f79c55acdcc6af406a9e03b469a4853eefee808..8e13fd9421635753f7b634ba4177b5df003a074f 100644 (file)
@@ -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;
@@ -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;