]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
f2fs: fix a redundant call to f2fs_balance_fs if an error occurs
authorColin Ian King <colin.king@canonical.com>
Thu, 4 Mar 2021 09:21:18 +0000 (09:21 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:08:25 +0000 (10:08 +0200)
[ Upstream commit 28e18ee636ba28532dbe425540af06245a0bbecb ]

The  uninitialized variable dn.node_changed does not get set when a
call to f2fs_get_node_page fails.  This uninitialized value gets used
in the call to f2fs_balance_fs() that may or not may not balances
dirty node and dentry pages depending on the uninitialized state of
the variable. Fix this by only calling f2fs_balance_fs if err is
not set.

Thanks to Jaegeuk Kim for suggesting an appropriate fix.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 2a3407607028 ("f2fs: call f2fs_balance_fs only when node was changed")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/f2fs/inline.c

index cbd17e4ff920c21ec319f1285c8262184c046131..c6bd669f4b4e6bbd3e0f1c1c52970877ef99a288 100644 (file)
@@ -216,7 +216,8 @@ out:
 
        f2fs_put_page(page, 1);
 
-       f2fs_balance_fs(sbi, dn.node_changed);
+       if (!err)
+               f2fs_balance_fs(sbi, dn.node_changed);
 
        return err;
 }