Skip to contentSkip to conversation

kobject: should use kobject_put() in kset-example

PATCH In review Li Zefan 2 participants 2 messages Jun 13, 2008

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 kobject: should use kobject_put() in kset-example

We should call kobject_put() instead of kfree() if kobject_init_and_add() returns an error, shouldn't we? Don't set up a bad example ;)

---
 samples/kobject/kset-example.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
samples/kobject/kset-example.c +1 -1
index b0a1b4f..7395c0b 100644
@@ -211,7 +211,7 @@ static struct foo_obj *create_foo_obj(const char *name)
 	 */
 	retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name);
 	if (retval) {
-		kfree(foo);
+		kobject_put(&foo->kobj);
 		return NULL;
 	}
 
Signature · 1 line
1.5.4.rc3
#1 lore raw
Quoted 2 lines · Li Zefan

We should call kobject_put() instead of kfree() if kobject_init_and_add() returns an error, shouldn't we? Don't set up a bad example ;)

Ah, good catch, you are right. I'll go add this to my queue, thanks for the patch.

greg k-h