]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/sysfs/symlink.c
[SPARC64]: Fix virq decomposition.
[linux-2.6-omap-h63xx.git] / fs / sysfs / symlink.c
index 2f86e04222907b2c19aab03adf6d2f2cabe092d1..4ce687f0b5d01751dfb8f8aa189c84360eaab39e 100644 (file)
@@ -86,7 +86,9 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
        sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
        if (!sd)
                goto out_put;
+
        sd->s_elem.symlink.target_sd = target_sd;
+       target_sd = NULL;       /* reference is now owned by the symlink */
 
        sysfs_addrm_start(&acxt, parent_sd);
 
@@ -95,11 +97,13 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
                sysfs_link_sibling(sd);
        }
 
-       if (sysfs_addrm_finish(&acxt))
-               return 0;
+       if (!sysfs_addrm_finish(&acxt)) {
+               error = -EEXIST;
+               goto out_put;
+       }
+
+       return 0;
 
-       error = -EEXIST;
-       /* fall through */
  out_put:
        sysfs_put(target_sd);
        sysfs_put(sd);