diff options
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/dir.c | 12 | ||||
-rw-r--r-- | fs/sysfs/file.c | 9 | ||||
-rw-r--r-- | fs/sysfs/symlink.c | 10 |
3 files changed, 18 insertions, 13 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 2e6775a836f2..048e6054c2fd 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -699,17 +699,19 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, | |||
699 | 699 | ||
700 | /* link in */ | 700 | /* link in */ |
701 | sysfs_addrm_start(&acxt, parent_sd); | 701 | sysfs_addrm_start(&acxt, parent_sd); |
702 | |||
702 | if (!sysfs_find_dirent(parent_sd, name)) { | 703 | if (!sysfs_find_dirent(parent_sd, name)) { |
703 | sysfs_add_one(&acxt, sd); | 704 | sysfs_add_one(&acxt, sd); |
704 | sysfs_link_sibling(sd); | 705 | sysfs_link_sibling(sd); |
705 | } | 706 | } |
706 | if (sysfs_addrm_finish(&acxt)) { | 707 | |
707 | *p_sd = sd; | 708 | if (!sysfs_addrm_finish(&acxt)) { |
708 | return 0; | 709 | sysfs_put(sd); |
710 | return -EEXIST; | ||
709 | } | 711 | } |
710 | 712 | ||
711 | sysfs_put(sd); | 713 | *p_sd = sd; |
712 | return -EEXIST; | 714 | return 0; |
713 | } | 715 | } |
714 | 716 | ||
715 | int sysfs_create_subdir(struct kobject *kobj, const char *name, | 717 | int sysfs_create_subdir(struct kobject *kobj, const char *name, |
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index cc497994b2a8..3e1cc062a740 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -410,11 +410,12 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr, | |||
410 | sysfs_link_sibling(sd); | 410 | sysfs_link_sibling(sd); |
411 | } | 411 | } |
412 | 412 | ||
413 | if (sysfs_addrm_finish(&acxt)) | 413 | if (!sysfs_addrm_finish(&acxt)) { |
414 | return 0; | 414 | sysfs_put(sd); |
415 | return -EEXIST; | ||
416 | } | ||
415 | 417 | ||
416 | sysfs_put(sd); | 418 | return 0; |
417 | return -EEXIST; | ||
418 | } | 419 | } |
419 | 420 | ||
420 | 421 | ||
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index d056e9695cd6..4ce687f0b5d0 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -97,11 +97,13 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char | |||
97 | sysfs_link_sibling(sd); | 97 | sysfs_link_sibling(sd); |
98 | } | 98 | } |
99 | 99 | ||
100 | if (sysfs_addrm_finish(&acxt)) | 100 | if (!sysfs_addrm_finish(&acxt)) { |
101 | return 0; | 101 | error = -EEXIST; |
102 | goto out_put; | ||
103 | } | ||
104 | |||
105 | return 0; | ||
102 | 106 | ||
103 | error = -EEXIST; | ||
104 | /* fall through */ | ||
105 | out_put: | 107 | out_put: |
106 | sysfs_put(target_sd); | 108 | sysfs_put(target_sd); |
107 | sysfs_put(sd); | 109 | sysfs_put(sd); |