kobject: make kset_create check kobject_set_name return value
authorDave Young <hidave.darkstar@gmail.com>
Mon, 11 May 2009 06:17:45 +0000 (14:17 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Jun 2009 04:30:24 +0000 (21:30 -0700)
kset_create 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>
lib/kobject.c

index bacf6fe4f7a0347bb958ebc85a059ab582eb93b4..b512b746d2aff464e1c18a01c53300ef7b6e68f4 100644 (file)
@@ -793,11 +793,16 @@ static struct kset *kset_create(const char *name,
                                struct kobject *parent_kobj)
 {
        struct kset *kset;
+       int retval;
 
        kset = kzalloc(sizeof(*kset), GFP_KERNEL);
        if (!kset)
                return NULL;
-       kobject_set_name(&kset->kobj, name);
+       retval = kobject_set_name(&kset->kobj, name);
+       if (retval) {
+               kfree(kset);
+               return NULL;
+       }
        kset->uevent_ops = uevent_ops;
        kset->kobj.parent = parent_kobj;