[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdk-fdJr9TcgUnOhCiU0LvD2Qe_c+6YOe-c1k0Ukm+negA@mail.gmail.com>
Date: Mon, 24 Jul 2023 10:19:02 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Su Hui <suhui@...china.com>
Cc: tytso@....edu, adilger.kernel@...ger.ca, nathan@...nel.org,
trix@...hat.com, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] ext4: mballoc: avoid garbage value from err
On Sun, Jul 23, 2023 at 10:46 PM Su Hui <suhui@...china.com> wrote:
>
> clang warning: fs/ext4/mballoc.c, line 4178, column 6
> Branch condition evaluates to a garbage value.
Specifically this is clang's static analysis; not the compiler itself.
>
> err is uninitialized and will be judged when it enters the
> loop first time and the condition "!ext4_sb_block_valid()"
> is true. Although this can't make problems now, it's better
> to correct it.
>
> Signed-off-by: Su Hui <suhui@...china.com>
Hi Su,
Thanks for the patch! I see what the warning is getting at;
If `len <= 0` then `err` is never initialized, then is used at line
4178 (that is UB).
Would you mind sending a v2 with the commit message updated to reflect
the above points? I'd be happy to sign-off on that.
> ---
> fs/ext4/mballoc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 21b903fe546e..769000c970b0 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4084,7 +4084,7 @@ void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block,
> struct ext4_sb_info *sbi = EXT4_SB(sb);
> ext4_group_t group;
> ext4_grpblk_t blkoff;
> - int i, err;
> + int i, err = 0;
> int already;
> unsigned int clen, clen_changed, thisgrp_len;
>
> --
> 2.30.2
>
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists