diff options
-rw-r--r-- | lib/kobject.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 03d40360ff1b..a7e3bf4d3c70 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -308,6 +308,19 @@ int kobject_rename(struct kobject * kobj, const char *new_name) | |||
308 | if (!kobj->parent) | 308 | if (!kobj->parent) |
309 | return -EINVAL; | 309 | return -EINVAL; |
310 | 310 | ||
311 | /* see if this name is already in use */ | ||
312 | if (kobj->kset) { | ||
313 | struct kobject *temp_kobj; | ||
314 | temp_kobj = kset_find_obj(kobj->kset, new_name); | ||
315 | if (temp_kobj) { | ||
316 | printk(KERN_WARNING "kobject '%s' can not be renamed " | ||
317 | "to '%s' as '%s' is already in existance.\n", | ||
318 | kobject_name(kobj), new_name, new_name); | ||
319 | kobject_put(temp_kobj); | ||
320 | return -EINVAL; | ||
321 | } | ||
322 | } | ||
323 | |||
311 | devpath = kobject_get_path(kobj, GFP_KERNEL); | 324 | devpath = kobject_get_path(kobj, GFP_KERNEL); |
312 | if (!devpath) { | 325 | if (!devpath) { |
313 | error = -ENOMEM; | 326 | error = -ENOMEM; |