fs/super.c: fix WARN on alloc_super() fail path
authorVladimir Davydov <vdavydov@parallels.com>
Tue, 21 Jan 2014 23:48:45 +0000 (15:48 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 22 Jan 2014 00:19:42 +0000 (16:19 -0800)
On fail path alloc_super() calls destroy_super(), which issues a warning
if the sb's s_mounts list is not empty, in particular if it has not been
initialized.  That said s_mounts must be initialized in alloc_super()
before any possible failure, but currently it is initialized close to
the end of the function leading to a useless warning dumped to log if
either percpu_counter_init() or list_lru_init() fails.  Let's fix this.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/super.c

index e5f6c2cfac380a7c4503dcebb0b3e310841893f0..cecd780e0f44ffed45f9b6ff9b540fadc34d5a3a 100644 (file)
@@ -166,6 +166,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
        if (!s)
                return NULL;
 
+       INIT_LIST_HEAD(&s->s_mounts);
+
        if (security_sb_alloc(s))
                goto fail;
 
@@ -188,7 +190,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
        if (list_lru_init(&s->s_inode_lru))
                goto fail;
 
-       INIT_LIST_HEAD(&s->s_mounts);
        init_rwsem(&s->s_umount);
        lockdep_set_class(&s->s_umount, &type->s_umount_key);
        /*