summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-01-21 11:55:11 -0800
committerStephen Rothwell <sfr@canb.auug.org.au>2009-02-02 09:48:30 +1100
commit236cd57b035fcc7f6575612c409eab84f986965a (patch)
treeb236689cf965af080648646065955ea4b3bef67d /fs
parent5bf2c2ff83f4674acc43aa1af5559ffd426e9b6c (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')
-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)
sysfs_sb = sb;
/* get root inode, initialize and unlock it */
+ mutex_lock(&sysfs_mutex);
inode = sysfs_get_inode(&sysfs_root);
+ mutex_unlock(&sysfs_mutex);
if (!inode) {
pr_debug("sysfs: could not get root inode\n");
return -ENOMEM;