aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/sysfs/dir.c6
-rw-r--r--include/linux/sysfs.h4
-rw-r--r--lib/kobject.c17
3 files changed, 17 insertions, 10 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index c18342641cec..3a05a596e3b4 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -829,16 +829,12 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
829 if (!new_dentry) 829 if (!new_dentry)
830 goto out_unlock; 830 goto out_unlock;
831 831
832 /* rename kobject and sysfs_dirent */ 832 /* rename sysfs_dirent */
833 error = -ENOMEM; 833 error = -ENOMEM;
834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL); 834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
835 if (!new_name) 835 if (!new_name)
836 goto out_unlock; 836 goto out_unlock;
837 837
838 error = kobject_set_name(kobj, "%s", new_name);
839 if (error)
840 goto out_unlock;
841
842 dup_name = sd->s_name; 838 dup_name = sd->s_name;
843 sd->s_name = new_name; 839 sd->s_name = new_name;
844 840
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 39924a962207..b330e289d71f 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -20,8 +20,6 @@
20struct kobject; 20struct kobject;
21struct module; 21struct module;
22 22
23extern int kobject_set_name(struct kobject *kobj, const char *name, ...)
24 __attribute__((format(printf, 2, 3)));
25/* FIXME 23/* FIXME
26 * The *owner field is no longer used, but leave around 24 * The *owner field is no longer used, but leave around
27 * until the tree gets cleaned up fully. 25 * until the tree gets cleaned up fully.
@@ -149,7 +147,7 @@ static inline void sysfs_remove_dir(struct kobject *kobj)
149 147
150static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name) 148static inline int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
151{ 149{
152 return kobject_set_name(kobj, "%s", new_name); 150 return 0;
153} 151}
154 152
155static inline int sysfs_move_dir(struct kobject *kobj, 153static inline int sysfs_move_dir(struct kobject *kobj,
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);