aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs/inode.c')
-rw-r--r--fs/sysfs/inode.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 3eab9c46a71b..732fd7f371e0 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -284,8 +284,8 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd)
284 284
285int sysfs_hash_and_remove(struct dentry * dir, const char * name) 285int sysfs_hash_and_remove(struct dentry * dir, const char * name)
286{ 286{
287 struct sysfs_dirent * sd; 287 struct sysfs_dirent **pos, *sd;
288 struct sysfs_dirent * parent_sd; 288 struct sysfs_dirent *parent_sd = dir->d_fsdata;
289 int found = 0; 289 int found = 0;
290 290
291 if (!dir) 291 if (!dir)
@@ -295,13 +295,15 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
295 /* no inode means this hasn't been made visible yet */ 295 /* no inode means this hasn't been made visible yet */
296 return -ENOENT; 296 return -ENOENT;
297 297
298 parent_sd = dir->d_fsdata;
299 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); 298 mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
300 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 299 for (pos = &parent_sd->s_children; *pos; pos = &(*pos)->s_sibling) {
300 sd = *pos;
301
301 if (!sd->s_type) 302 if (!sd->s_type)
302 continue; 303 continue;
303 if (!strcmp(sd->s_name, name)) { 304 if (!strcmp(sd->s_name, name)) {
304 list_del_init(&sd->s_sibling); 305 *pos = sd->s_sibling;
306 sd->s_sibling = NULL;
305 found = 1; 307 found = 1;
306 break; 308 break;
307 } 309 }