From: Li Zefan <lizf@cn.fujitsu.com>
To: Greg KH <gregkh@suse.de>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] kobject: should use kobject_put() in kset-example
Date: Fri, 13 Jun 2008 11:09:16 +0800 [thread overview]
Message-ID: <4851E4DC.6040603@cn.fujitsu.com> (raw)
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
next reply other threads:[~2008-06-13 3:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-13 3:09 Li Zefan [this message]
2008-06-13 3:39 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4851E4DC.6040603@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®