All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kobject: should use kobject_put() in kset-example
@ 2008-06-13  3:09 Li Zefan
  2008-06-13  3:39 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Li Zefan @ 2008-06-13  3:09 UTC (permalink / raw)
  To: Greg KH, LKML

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 ;)

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 samples/kobject/kset-example.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
index b0a1b4f..7395c0b 100644
--- a/samples/kobject/kset-example.c
+++ b/samples/kobject/kset-example.c
@@ -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;
 	}
 
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kobject: should use kobject_put() in kset-example
  2008-06-13  3:09 [PATCH] kobject: should use kobject_put() in kset-example Li Zefan
@ 2008-06-13  3:39 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2008-06-13  3:39 UTC (permalink / raw)
  To: Li Zefan; +Cc: LKML

On Fri, Jun 13, 2008 at 11:09:16AM +0800, Li Zefan wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-13  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13  3:09 [PATCH] kobject: should use kobject_put() in kset-example Li Zefan
2008-06-13  3:39 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.