diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index fd7874032163..718e5101c263 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -216,21 +216,12 @@ static int kobject_add_internal(struct kobject *kobj) | |||
216 | static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, | 216 | static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, |
217 | va_list vargs) | 217 | va_list vargs) |
218 | { | 218 | { |
219 | va_list aq; | ||
220 | char *name; | ||
221 | |||
222 | va_copy(aq, vargs); | ||
223 | name = kvasprintf(GFP_KERNEL, fmt, vargs); | ||
224 | va_end(aq); | ||
225 | |||
226 | if (!name) | ||
227 | return -ENOMEM; | ||
228 | |||
229 | /* Free the old name, if necessary. */ | 219 | /* Free the old name, if necessary. */ |
230 | kfree(kobj->name); | 220 | kfree(kobj->name); |
231 | 221 | ||
232 | /* Now, set the new name */ | 222 | kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); |
233 | kobj->name = name; | 223 | if (!kobj->name) |
224 | return -ENOMEM; | ||
234 | 225 | ||
235 | return 0; | 226 | return 0; |
236 | } | 227 | } |
@@ -246,12 +237,12 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, | |||
246 | */ | 237 | */ |
247 | int kobject_set_name(struct kobject *kobj, const char *fmt, ...) | 238 | int kobject_set_name(struct kobject *kobj, const char *fmt, ...) |
248 | { | 239 | { |
249 | va_list args; | 240 | va_list vargs; |
250 | int retval; | 241 | int retval; |
251 | 242 | ||
252 | va_start(args, fmt); | 243 | va_start(vargs, fmt); |
253 | retval = kobject_set_name_vargs(kobj, fmt, args); | 244 | retval = kobject_set_name_vargs(kobj, fmt, vargs); |
254 | va_end(args); | 245 | va_end(vargs); |
255 | 246 | ||
256 | return retval; | 247 | return retval; |
257 | } | 248 | } |
@@ -301,12 +292,9 @@ EXPORT_SYMBOL(kobject_init); | |||
301 | static int kobject_add_varg(struct kobject *kobj, struct kobject *parent, | 292 | static int kobject_add_varg(struct kobject *kobj, struct kobject *parent, |
302 | const char *fmt, va_list vargs) | 293 | const char *fmt, va_list vargs) |
303 | { | 294 | { |
304 | va_list aq; | ||
305 | int retval; | 295 | int retval; |
306 | 296 | ||
307 | va_copy(aq, vargs); | 297 | retval = kobject_set_name_vargs(kobj, fmt, vargs); |
308 | retval = kobject_set_name_vargs(kobj, fmt, aq); | ||
309 | va_end(aq); | ||
310 | if (retval) { | 298 | if (retval) { |
311 | printk(KERN_ERR "kobject: can not set name properly!\n"); | 299 | printk(KERN_ERR "kobject: can not set name properly!\n"); |
312 | return retval; | 300 | return retval; |