Skip to content

Commit

Permalink
f2fs: fix a redundant call to f2fs_balance_fs if an error occurs
Browse files Browse the repository at this point in the history
[ Upstream commit 28e18ee ]

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: 2a34076 ("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>
  • Loading branch information
Colin Ian King authored and gregkh committed May 19, 2021
1 parent 1c20a48 commit 2d6d5b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/f2fs/inline.c
Expand Up @@ -218,7 +218,8 @@ int f2fs_convert_inline_inode(struct inode *inode)

f2fs_put_page(page, 1);

f2fs_balance_fs(sbi, dn.node_changed);
if (!err)
f2fs_balance_fs(sbi, dn.node_changed);

return err;
}
Expand Down

0 comments on commit 2d6d5b4

Please sign in to comment.