aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-01-21 14:55:11 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:38:24 -0400
commit4a67a1bc0b3a0db017b560cee27370d141c58e25 (patch)
treeab039581d41c9fa45a1bac9eb843baa1312a5969 /fs/sysfs
parent8231f2f99a5e5fc45a25e8de09fd1ab9711babf1 (diff)
sysfs: Take sysfs_mutex when fetching the root inode.
sysfs_get_inode ultimately calls sysfs_count_nlink when the a directory inode is fectched. sysfs_count_nlink needs to be called under the sysfs_mutex to guard against the unlikely but possible scenario that the root directory is changing as we are counting the number entries in it, and just in general to be consistent. Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/mount.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 8133ca36ee0e..84ef378673a8 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -52,7 +52,9 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
52 sysfs_sb = sb; 52 sysfs_sb = sb;
53 53
54 /* get root inode, initialize and unlock it */ 54 /* get root inode, initialize and unlock it */
55 mutex_lock(&sysfs_mutex);
55 inode = sysfs_get_inode(&sysfs_root); 56 inode = sysfs_get_inode(&sysfs_root);
57 mutex_unlock(&sysfs_mutex);
56 if (!inode) { 58 if (!inode) {
57 pr_debug("sysfs: could not get root inode\n"); 59 pr_debug("sysfs: could not get root inode\n");
58 return -ENOMEM; 60 return -ENOMEM;