[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>
This commit is contained in:
Maneesh Soni
2006-03-09 19:40:14 +05:30
committed by Greg Kroah-Hartman
parent 22f98c0cd7
commit c516865cfb
4 changed files with 39 additions and 5 deletions
+3 -2
View File
@@ -82,12 +82,13 @@ exit1:
int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
{
struct dentry * dentry = kobj->dentry;
int error = 0;
int error = -EEXIST;
BUG_ON(!kobj || !kobj->dentry || !name);
mutex_lock(&dentry->d_inode->i_mutex);
error = sysfs_add_link(dentry, name, target);
if (!sysfs_dirent_exist(dentry->d_fsdata, name))
error = sysfs_add_link(dentry, name, target);
mutex_unlock(&dentry->d_inode->i_mutex);
return error;
}