From 17707bfe9855c783856a73bd8e7d62bc9361cf58 Mon Sep 17 00:00:00 2001 From: Fengnan Chang Date: Sat, 22 May 2021 11:57:20 +0000 Subject: [PATCH] ext4: fix error code in ext4_commit_super stable inclusion from stable-5.10.36 commit 12905cf9e5c418fe8ad45e56d8d79848c6b11558 bugzilla: 51867 CVE: NA -------------------------------- commit f88f1466e2a2e5ca17dfada436d3efa1b03a3972 upstream. We should set the error code when ext4_commit_super check argument failed. Found in code review. Fixes: c4be0c1dc4cdc ("filesystem freeze: add error handling of write_super_lockfs/unlockfs"). Cc: stable@kernel.org Signed-off-by: Fengnan Chang Reviewed-by: Andreas Dilger Link: https://lore.kernel.org/r/20210402101631.561-1-changfengnan@vivo.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman Signed-off-by: Chen Jun Conflicts: fs/ext4/super.c Acked-by: Weilong Chen Signed-off-by: Zheng Zengkai --- fs/ext4/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9696c0cd729d..21f9ad383214 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5553,8 +5553,10 @@ static int ext4_commit_super(struct super_block *sb) struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; int error = 0; - if (!sbh || block_device_ejected(sb)) - return error; + if (!sbh) + return -EINVAL; + if (block_device_ejected(sb)) + return -ENODEV; ext4_update_super(sb); -- GitLab