]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - lib/kobject.c
Merge branch 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
[karo-tx-linux.git] / lib / kobject.c
index 53bfc853cd8c629298626bf87090b2a9e4e44537..2e3bd01964a9047f481862c2323be8c4ea42db9c 100644 (file)
@@ -257,23 +257,20 @@ static int kobject_add_internal(struct kobject *kobj)
 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
                                  va_list vargs)
 {
-       const char *old_name = kobj->name;
        char *s;
 
        if (kobj->name && !fmt)
                return 0;
 
-       kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
-       if (!kobj->name) {
-               kobj->name = old_name;
+       s = kvasprintf(GFP_KERNEL, fmt, vargs);
+       if (!s)
                return -ENOMEM;
-       }
 
        /* ewww... some of these buggers have '/' in the name ... */
-       while ((s = strchr(kobj->name, '/')))
-               s[0] = '!';
+       strreplace(s, '/', '!');
+       kfree(kobj->name);
+       kobj->name = s;
 
-       kfree(old_name);
        return 0;
 }