driver-core: make sysdev_class_register check kobject_set_name return value
authorDave Young <hidave.darkstar@gmail.com>
Mon, 11 May 2009 06:18:55 +0000 (14:18 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Jun 2009 04:30:24 +0000 (21:30 -0700)
sysdev_class_register should check the kobject_set_name return value.

Add the return value checking code.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/sys.c

index 9742a78c9fe42a043bfa0c57e89ead65e4f6fc2f..162355cd745a1323fc4ee2a0b1860d9e635a7047 100644 (file)
@@ -131,6 +131,8 @@ static struct kset *system_kset;
 
 int sysdev_class_register(struct sysdev_class *cls)
 {
+       int retval;
+
        pr_debug("Registering sysdev class '%s'\n", cls->name);
 
        INIT_LIST_HEAD(&cls->drivers);
@@ -138,7 +140,11 @@ int sysdev_class_register(struct sysdev_class *cls)
        cls->kset.kobj.parent = &system_kset->kobj;
        cls->kset.kobj.ktype = &ktype_sysdev_class;
        cls->kset.kobj.kset = system_kset;
-       kobject_set_name(&cls->kset.kobj, cls->name);
+
+       retval = kobject_set_name(&cls->kset.kobj, cls->name);
+       if (retval)
+               return retval;
+
        return kset_register(&cls->kset);
 }