aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 718e5101c263..fbf0ae282376 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -164,9 +164,8 @@ static int kobject_add_internal(struct kobject *kobj)
164 return -ENOENT; 164 return -ENOENT;
165 165
166 if (!kobj->name || !kobj->name[0]) { 166 if (!kobj->name || !kobj->name[0]) {
167 pr_debug("kobject: (%p): attempted to be registered with empty " 167 WARN(1, "kobject: (%p): attempted to be registered with empty "
168 "name!\n", kobj); 168 "name!\n", kobj);
169 WARN_ON(1);
170 return -EINVAL; 169 return -EINVAL;
171 } 170 }
172 171
@@ -216,13 +215,18 @@ static int kobject_add_internal(struct kobject *kobj)
216static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 215static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
217 va_list vargs) 216 va_list vargs)
218{ 217{
219 /* Free the old name, if necessary. */ 218 const char *old_name = kobj->name;
220 kfree(kobj->name); 219 char *s;
221 220
222 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); 221 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
223 if (!kobj->name) 222 if (!kobj->name)
224 return -ENOMEM; 223 return -ENOMEM;
225 224
225 /* ewww... some of these buggers have '/' in the name ... */
226 while ((s = strchr(kobj->name, '/')))
227 s[0] = '!';
228
229 kfree(old_name);
226 return 0; 230 return 0;
227} 231}
228 232
@@ -439,6 +443,7 @@ out:
439 443
440 return error; 444 return error;
441} 445}
446EXPORT_SYMBOL_GPL(kobject_rename);
442 447
443/** 448/**
444 * kobject_move - move object to another parent 449 * kobject_move - move object to another parent
@@ -576,12 +581,10 @@ static void kobject_release(struct kref *kref)
576void kobject_put(struct kobject *kobj) 581void kobject_put(struct kobject *kobj)
577{ 582{
578 if (kobj) { 583 if (kobj) {
579 if (!kobj->state_initialized) { 584 if (!kobj->state_initialized)
580 printk(KERN_WARNING "kobject: '%s' (%p): is not " 585 WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
581 "initialized, yet kobject_put() is being " 586 "initialized, yet kobject_put() is being "
582 "called.\n", kobject_name(kobj), kobj); 587 "called.\n", kobject_name(kobj), kobj);
583 WARN_ON(1);
584 }
585 kref_put(&kobj->kref, kobject_release); 588 kref_put(&kobj->kref, kobject_release);
586 } 589 }
587} 590}