Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=34358c26a2c96b2a068dc44e0ac602106a466bce
Commit:     34358c26a2c96b2a068dc44e0ac602106a466bce
Parent:     fcd239d3d5575e5cc63aab5c33cf6dc66904f6d6
Author:     Greg Kroah-Hartman <[EMAIL PROTECTED]>
AuthorDate: Wed Oct 24 16:52:31 2007 -0700
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Tue Oct 30 21:52:33 2007 -0700

    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 <[EMAIL PROTECTED]>
    Cc: Kay Sievers <[EMAIL PROTECTED]>
    Cc: Rafael J. Wysocki <[EMAIL PROTECTED]>
    Cc: Tejun Heo <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 lib/kobject.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 03d4036..a7e3bf4 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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to