aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2008-07-03 21:05:28 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-16 12:24:52 -0400
commit0b4a4fea253e1296222603ccc55430ed7cd9413a (patch)
tree5ce1810393a0f3a48ac208e0dbf994b63a481f18 /lib
parent030c1d2bfcc2187650fb975456ca0b61a5bb77f4 (diff)
kobject: Cleanup kobject_rename and !CONFIG_SYSFS
It finally dawned on me what the clean fix to sysfs_rename_dir calling kobject_set_name is. Move the work into kobject_rename where it belongs. The callers serialize us anyway so this is safe. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/kobject.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index ae6bb900bfb6..0487d1f64806 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -397,6 +397,7 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
397{ 397{
398 int error = 0; 398 int error = 0;
399 const char *devpath = NULL; 399 const char *devpath = NULL;
400 const char *dup_name = NULL, *name;
400 char *devpath_string = NULL; 401 char *devpath_string = NULL;
401 char *envp[2]; 402 char *envp[2];
402 403
@@ -420,15 +421,27 @@ int kobject_rename(struct kobject *kobj, const char *new_name)
420 envp[0] = devpath_string; 421 envp[0] = devpath_string;
421 envp[1] = NULL; 422 envp[1] = NULL;
422 423
424 name = dup_name = kstrdup(new_name, GFP_KERNEL);
425 if (!name) {
426 error = -ENOMEM;
427 goto out;
428 }
429
423 error = sysfs_rename_dir(kobj, new_name); 430 error = sysfs_rename_dir(kobj, new_name);
431 if (error)
432 goto out;
433
434 /* Install the new kobject name */
435 dup_name = kobj->name;
436 kobj->name = name;
424 437
425 /* This function is mostly/only used for network interface. 438 /* This function is mostly/only used for network interface.
426 * Some hotplug package track interfaces by their name and 439 * Some hotplug package track interfaces by their name and
427 * therefore want to know when the name is changed by the user. */ 440 * therefore want to know when the name is changed by the user. */
428 if (!error) 441 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
429 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
430 442
431out: 443out:
444 kfree(dup_name);
432 kfree(devpath_string); 445 kfree(devpath_string);
433 kfree(devpath); 446 kfree(devpath);
434 kobject_put(kobj); 447 kobject_put(kobj);