diff options
author | Maneesh Soni <maneesh@in.ibm.com> | 2006-03-09 09:10:14 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-20 16:42:59 -0500 |
commit | c516865cfbac0d862d4888df91793ad1e74ffd58 (patch) | |
tree | 432024125976af3e6c87ae5b9e64b6f1cc291f70 /fs/sysfs/symlink.c | |
parent | 22f98c0cd7e003b896ee52ded945081307118745 (diff) |
[PATCH] sysfs: fix problem with duplicate sysfs directories and files
The following patch checks for existing sysfs_dirent before
preparing new one while creating sysfs directories and files.
Signed-off-by: Maneesh Soni <maneesh@in.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r-- | fs/sysfs/symlink.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index e38d6338a20d..fe23f47f6e43 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -82,12 +82,13 @@ exit1: | |||
82 | int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) | 82 | int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) |
83 | { | 83 | { |
84 | struct dentry * dentry = kobj->dentry; | 84 | struct dentry * dentry = kobj->dentry; |
85 | int error = 0; | 85 | int error = -EEXIST; |
86 | 86 | ||
87 | BUG_ON(!kobj || !kobj->dentry || !name); | 87 | BUG_ON(!kobj || !kobj->dentry || !name); |
88 | 88 | ||
89 | mutex_lock(&dentry->d_inode->i_mutex); | 89 | mutex_lock(&dentry->d_inode->i_mutex); |
90 | error = sysfs_add_link(dentry, name, target); | 90 | if (!sysfs_dirent_exist(dentry->d_fsdata, name)) |
91 | error = sysfs_add_link(dentry, name, target); | ||
91 | mutex_unlock(&dentry->d_inode->i_mutex); | 92 | mutex_unlock(&dentry->d_inode->i_mutex); |
92 | return error; | 93 | return error; |
93 | } | 94 | } |