diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2015-06-25 18:02:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-25 20:00:40 -0400 |
commit | 2abf114fc841550a3e0c63afcd31c9781116fe42 (patch) | |
tree | f0bbf3994dba58d7bb4fe98129d68250fd1df6fb /lib/kobject.c | |
parent | ff14417c0a00c9a906b4ba79fbecb79bd2435207 (diff) |
lib/kobject.c: use strreplace()
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>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r-- | lib/kobject.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 3b841b97fccd..75ee63834fd1 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -257,23 +257,20 @@ static int kobject_add_internal(struct kobject *kobj) | |||
257 | int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, | 257 | int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, |
258 | va_list vargs) | 258 | va_list vargs) |
259 | { | 259 | { |
260 | const char *old_name = kobj->name; | ||
261 | char *s; | 260 | char *s; |
262 | 261 | ||
263 | if (kobj->name && !fmt) | 262 | if (kobj->name && !fmt) |
264 | return 0; | 263 | return 0; |
265 | 264 | ||
266 | kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); | 265 | s = kvasprintf(GFP_KERNEL, fmt, vargs); |
267 | if (!kobj->name) { | 266 | if (!s) |
268 | kobj->name = old_name; | ||
269 | return -ENOMEM; | 267 | return -ENOMEM; |
270 | } | ||
271 | 268 | ||
272 | /* ewww... some of these buggers have '/' in the name ... */ | 269 | /* ewww... some of these buggers have '/' in the name ... */ |
273 | while ((s = strchr(kobj->name, '/'))) | 270 | strreplace(s, '/', '!'); |
274 | s[0] = '!'; | 271 | kfree(kobj->name); |
272 | kobj->name = s; | ||
275 | 273 | ||
276 | kfree(old_name); | ||
277 | return 0; | 274 | return 0; |
278 | } | 275 | } |
279 | 276 | ||