Skip to content

Commit

Permalink
lib/kobject.c: use strreplace()
Browse files Browse the repository at this point in the history
There's probably not many slashes in the name, but starting over when
we see one feels wrong.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rasmus Villemoes authored and Linus Torvalds committed Jun 26, 2015
1 parent ff14417 commit 2abf114
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2abf114

Please sign in to comment.