]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ovl: fix bogus -Wmaybe-unitialized warning
authorArnd Bergmann <arnd@arndb.de>
Mon, 17 Jun 2019 12:39:29 +0000 (14:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jun 2019 03:35:52 +0000 (11:35 +0800)
[ Upstream commit 1dac6f5b0ed2601be21bb4e27a44b0c3e667b7f4 ]

gcc gets a bit confused by the logic in ovl_setup_trap() and
can't figure out whether the local 'trap' variable in the caller
was initialized or not:

fs/overlayfs/super.c: In function 'ovl_fill_super':
fs/overlayfs/super.c:1333:4: error: 'trap' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    iput(trap);
    ^~~~~~~~~~
fs/overlayfs/super.c:1312:17: note: 'trap' was declared here

Reword slightly to make it easier for the compiler to understand.

Fixes: 146d62e5a586 ("ovl: detect overlapping layers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/overlayfs/super.c

index d6e60a7156a1933d79ac03acb92ca0d8d1ddcd0c..2d028c02621fa82ea7bb819d3aa5886014d8e7cc 100644 (file)
@@ -996,8 +996,8 @@ static int ovl_setup_trap(struct super_block *sb, struct dentry *dir,
        int err;
 
        trap = ovl_get_trap_inode(sb, dir);
-       err = PTR_ERR(trap);
-       if (IS_ERR(trap)) {
+       err = PTR_ERR_OR_ZERO(trap);
+       if (err) {
                if (err == -ELOOP)
                        pr_err("overlayfs: conflicting %s path\n", name);
                return err;