[PATCH] cmd: mtd: Prevent use of uninitialised variable

Andrew Goodbody andrew.goodbody at linaro.org
Thu Jul 24 10:58:30 CEST 2025


ping?

On 26/06/2025 11:49, Andrew Goodbody wrote:
> ret maybe used uninitialised in some cases so instead
> initialise it first to prevent this.
> 
> This issue was found by Smatch.
> 
> Fixes: 9671243e8d10 (cmd: mtd: Use the subcmd infrastructure to declare mtd sub-commands)
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
> ---
>   cmd/mtd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmd/mtd.c b/cmd/mtd.c
> index c25997cfb24..1651a4a6b3e 100644
> --- a/cmd/mtd.c
> +++ b/cmd/mtd.c
> @@ -474,7 +474,7 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
>   	struct mtd_info *mtd;
>   	u32 oob_len;
>   	u8 *buf;
> -	int ret;
> +	int ret = CMD_RET_SUCCESS;
>   
>   	if (argc < 2)
>   		return CMD_RET_USAGE;
> 
> ---
> base-commit: 903eb123236ccbd8ef05d43507a2a910b785bd56
> change-id: 20250626-mtd_fix-bb1ae86f33aa
> 
> Best regards,



More information about the U-Boot mailing list