kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix a redundant call to f2fs_balance_fs if an error occurs
@ 2021-03-04  9:21 Colin King
  2021-03-05  1:19 ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-03-04  9:21 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, linux-f2fs-devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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>
---
 fs/f2fs/inline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 993caefcd2bb..92652ca7a7c8 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -219,7 +219,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;
 }
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix a redundant call to f2fs_balance_fs if an error occurs
  2021-03-04  9:21 [PATCH] f2fs: fix a redundant call to f2fs_balance_fs if an error occurs Colin King
@ 2021-03-05  1:19 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2021-03-05  1:19 UTC (permalink / raw)
  To: Colin King, Jaegeuk Kim, Chao Yu, linux-f2fs-devel
  Cc: kernel-janitors, linux-kernel

On 2021/3/4 17:21, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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>

Thanks,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-05  1:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04  9:21 [PATCH] f2fs: fix a redundant call to f2fs_balance_fs if an error occurs Colin King
2021-03-05  1:19 ` [f2fs-dev] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).