diff options
Diffstat (limited to 'fs/sysfs/inode.c')
-rw-r--r-- | fs/sysfs/inode.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index e4c23939fb36..d439c0b4bfce 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -277,20 +277,14 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd) | |||
277 | 277 | ||
278 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) | 278 | int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) |
279 | { | 279 | { |
280 | struct dentry *dir; | ||
281 | struct sysfs_dirent **pos, *sd; | 280 | struct sysfs_dirent **pos, *sd; |
282 | int found = 0; | 281 | int found = 0; |
283 | 282 | ||
284 | if (!dir_sd) | 283 | if (!dir_sd) |
285 | return -ENOENT; | 284 | return -ENOENT; |
286 | 285 | ||
287 | dir = dir_sd->s_dentry; | 286 | mutex_lock(&sysfs_mutex); |
288 | 287 | ||
289 | if (dir->d_inode == NULL) | ||
290 | /* no inode means this hasn't been made visible yet */ | ||
291 | return -ENOENT; | ||
292 | |||
293 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT); | ||
294 | for (pos = &dir_sd->s_children; *pos; pos = &(*pos)->s_sibling) { | 288 | for (pos = &dir_sd->s_children; *pos; pos = &(*pos)->s_sibling) { |
295 | sd = *pos; | 289 | sd = *pos; |
296 | 290 | ||
@@ -304,7 +298,8 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name) | |||
304 | break; | 298 | break; |
305 | } | 299 | } |
306 | } | 300 | } |
307 | mutex_unlock(&dir->d_inode->i_mutex); | 301 | |
302 | mutex_unlock(&sysfs_mutex); | ||
308 | 303 | ||
309 | if (!found) | 304 | if (!found) |
310 | return -ENOENT; | 305 | return -ENOENT; |