lkml.org 
[lkml]   [2007]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH -mm] kobject_add error handling when set name failed
In kobject_add, when kobject_set_name failed we should put the kobj and return.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com>

---
lib/kobject.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff -upr linux/lib/kobject.c linux.new/lib/kobject.c
--- linux/lib/kobject.c 2007-12-14 17:14:03.000000000 +0800
+++ linux.new/lib/kobject.c 2007-12-14 17:17:48.000000000 +0800
@@ -228,8 +228,13 @@ int kobject_add(struct kobject * kobj)

if (!(kobj = kobject_get(kobj)))
return -ENOENT;
- if (!kobj->k_name)
- kobject_set_name(kobj, "NO_NAME");
+ if (!kobj->k_name) {
+ error = kobject_set_name(kobj, "NO_NAME"));
+ if (error) {
+ kobject_put(kobj);
+ return error;
+ }
+ }
if (!*kobj->k_name) {
pr_debug("kobject (%p) attempted to be registered with no "
"name!\n", kobj);
@@ -371,7 +376,7 @@ void kobject_init_ng(struct kobject *kob
goto error;
}
if (!ktype) {
- err_str = "must have a ktype to be initialized properly!\n";
+ err_str = "must have a ktype to be initialized properly!";
goto error;
}
if (atomic_read(&kobj->kref.refcount)) {

\
 
 \ /
  Last update: 2007-12-14 10:21    [W:0.390 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site