]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: mtd: Prevent use of uninitialised variable
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Thu, 26 Jun 2025 10:49:32 +0000 (11:49 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 28 Oct 2025 18:10:47 +0000 (12:10 -0600)
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@linaro.org>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
cmd/mtd.c

index acd886da6da7bc2c8a8ff646b90da6154dc45346..d0072129659c92273f4cbeda5396d4665e9daf57 100644 (file)
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -477,7 +477,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;