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 dcade0543bd2..bd732ffebc85 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,19 @@ 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 s = strchr(kobj->name, '/');
227 if (s)
228 s[0] = '!';
229
230 kfree(old_name);
226 return 0; 231 return 0;
227} 232}
228 233
@@ -577,12 +582,10 @@ static void kobject_release(struct kref *kref)
577void kobject_put(struct kobject *kobj) 582void kobject_put(struct kobject *kobj)
578{ 583{
579 if (kobj) { 584 if (kobj) {
580 if (!kobj->state_initialized) { 585 if (!kobj->state_initialized)
581 printk(KERN_WARNING "kobject: '%s' (%p): is not " 586 WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
582 "initialized, yet kobject_put() is being " 587 "initialized, yet kobject_put() is being "
583 "called.\n", kobject_name(kobj), kobj); 588 "called.\n", kobject_name(kobj), kobj);
584 WARN_ON(1);
585 }
586 kref_put(&kobj->kref, kobject_release); 589 kref_put(&kobj->kref, kobject_release);
587 } 590 }
588} 591}