diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-25 01:52:31 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-31 05:52:33 +0100 |
commit | 34358c26a2c96b2a068dc44e0ac602106a466bce (patch) | |
tree | 36820739660152337e8e6fcbf4f21d97d1525208 /lib/kobject.c | |
parent | Driver core: remove class_device_*_bin_file (diff) | |
download | linux-34358c26a2c96b2a068dc44e0ac602106a466bce.tar.xz linux-34358c26a2c96b2a068dc44e0ac602106a466bce.zip |
kobject: check for duplicate names in kobject_rename
This should catch any duplicate names before we try to tell sysfs to
rename the object. This happens a lot with older versions of udev and
the network rename scripts.
Cc: David Miller <davem@davemloft.net>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject.c')
-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) if (!kobj->parent) return -EINVAL; + /* see if this name is already in use */ + if (kobj->kset) { + struct kobject *temp_kobj; + temp_kobj = kset_find_obj(kobj->kset, new_name); + if (temp_kobj) { + printk(KERN_WARNING "kobject '%s' can not be renamed " + "to '%s' as '%s' is already in existance.\n", + kobject_name(kobj), new_name, new_name); + kobject_put(temp_kobj); + return -EINVAL; + } + } + devpath = kobject_get_path(kobj, GFP_KERNEL); if (!devpath) { error = -ENOMEM; |