[PATCH 2/3] kobject : make kset_create check kobject_set_name return value

From: Dave Young
Date: Mon May 11 2009 - 02:17:58 EST


kset_create should check the kobject_set_name return value.

Add the return value checking code.

Signed-off-by: Dave Young <hidave.darkstar@xxxxxxxxx>
---
lib/kobject.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff -uprN linux.old/lib/kobject.c linux.new/lib/kobject.c
--- linux.old/lib/kobject.c 2009-05-11 13:59:01.000000000 +0800
+++ linux.new/lib/kobject.c 2009-05-11 14:00:39.000000000 +0800
@@ -793,11 +793,16 @@ static struct kset *kset_create(const ch
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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/