[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:
committed by
Greg Kroah-Hartman
parent
22f98c0cd7
commit
c516865cfb
@@ -361,10 +361,12 @@ int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
|
||||
{
|
||||
struct sysfs_dirent * parent_sd = dir->d_fsdata;
|
||||
umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG;
|
||||
int error = 0;
|
||||
int error = -EEXIST;
|
||||
|
||||
mutex_lock(&dir->d_inode->i_mutex);
|
||||
error = sysfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type);
|
||||
if (!sysfs_dirent_exist(parent_sd, attr->name))
|
||||
error = sysfs_make_dirent(parent_sd, NULL, (void *)attr,
|
||||
mode, type);
|
||||
mutex_unlock(&dir->d_inode->i_mutex);
|
||||
|
||||
return error;
|
||||
|
Reference in New Issue
Block a user