2021-04-02 10:17:19

by 常凤楠

[permalink] [raw]
Subject: [PATCH v2] ext4: fix error code in ext4_commit_super

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").

Signed-off-by: Fengnan Chang <[email protected]>
---
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 03373471131c..1130599c87dc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5500,8 +5500,10 @@ static int ext4_commit_super(struct super_block *sb, int sync)
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;

/*
* If the file system is mounted read-only, don't update the
--
2.29.0


2021-04-03 18:35:34

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH v2] ext4: fix error code in ext4_commit_super

On Apr 2, 2021, at 4:16 AM, Fengnan Chang <[email protected]> wrote:
>
> 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").
>
> Signed-off-by: Fengnan Chang <[email protected]>

Reviewed-by: Andreas Dilger <[email protected]>

> ---
> 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 03373471131c..1130599c87dc 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5500,8 +5500,10 @@ static int ext4_commit_super(struct super_block *sb, int sync)
> 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;
>
> /*
> * If the file system is mounted read-only, don't update the
> --
> 2.29.0
>


Cheers, Andreas






Attachments:
signature.asc (890.00 B)
Message signed with OpenPGP

2021-04-09 22:46:12

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH v2] ext4: fix error code in ext4_commit_super

On Sat, Apr 03, 2021 at 12:34:50PM -0600, Andreas Dilger wrote:
> On Apr 2, 2021, at 4:16 AM, Fengnan Chang <[email protected]> wrote:
> >
> > 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").
> >
> > Signed-off-by: Fengnan Chang <[email protected]>
>
> Reviewed-by: Andreas Dilger <[email protected]>

Thanks, applied.

- Ted