diff options
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r-- | fs/sysfs/symlink.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index 683316f0aa96..2f86e0422290 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -55,6 +55,7 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char | |||
55 | struct sysfs_dirent *parent_sd = NULL; | 55 | struct sysfs_dirent *parent_sd = NULL; |
56 | struct sysfs_dirent *target_sd = NULL; | 56 | struct sysfs_dirent *target_sd = NULL; |
57 | struct sysfs_dirent *sd = NULL; | 57 | struct sysfs_dirent *sd = NULL; |
58 | struct sysfs_addrm_cxt acxt; | ||
58 | int error; | 59 | int error; |
59 | 60 | ||
60 | BUG_ON(!name); | 61 | BUG_ON(!name); |
@@ -87,17 +88,18 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char | |||
87 | goto out_put; | 88 | goto out_put; |
88 | sd->s_elem.symlink.target_sd = target_sd; | 89 | sd->s_elem.symlink.target_sd = target_sd; |
89 | 90 | ||
90 | mutex_lock(&sysfs_mutex); | 91 | sysfs_addrm_start(&acxt, parent_sd); |
91 | error = -EEXIST; | ||
92 | if (sysfs_find_dirent(parent_sd, name)) | ||
93 | goto out_unlock; | ||
94 | sysfs_attach_dirent(sd, parent_sd, NULL); | ||
95 | mutex_unlock(&sysfs_mutex); | ||
96 | 92 | ||
97 | return 0; | 93 | if (!sysfs_find_dirent(parent_sd, name)) { |
94 | sysfs_add_one(&acxt, sd); | ||
95 | sysfs_link_sibling(sd); | ||
96 | } | ||
98 | 97 | ||
99 | out_unlock: | 98 | if (sysfs_addrm_finish(&acxt)) |
100 | mutex_unlock(&sysfs_mutex); | 99 | return 0; |
100 | |||
101 | error = -EEXIST; | ||
102 | /* fall through */ | ||
101 | out_put: | 103 | out_put: |
102 | sysfs_put(target_sd); | 104 | sysfs_put(target_sd); |
103 | sysfs_put(sd); | 105 | sysfs_put(sd); |