cmd: mtd: Prevent use of uninitialised variable
PATCH 1/1 cmd: mtd: Prevent use of uninitialised variable
ret maybe used uninitialised in some cases so instead initialise it first to prevent this.
This issue was found by Smatch.
--- cmd/mtd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/mtd.c +1 -1
@@ -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,
Signature · 1 line
Andrew Goodbody <[email protected]>
Hi Andrew,
Quoted 3 lines · Andrew Goodbody
ret maybe used uninitialised in some cases so instead initialise it first to prevent this.
I don't believe that's true, can you tell us which code path(s) could trigger this because I didn't find one the 2min I spent reading the code.
Quoted 2 lines
This issue was found by Smatch.
Seems like a false positive to me?
Cheers,
Quentin
Quoted 8 lines · Quentin Schulz
Hi Andrew,
Quoted 3 lines · Andrew Goodbody
ret maybe used uninitialised in some cases so instead initialise it first to prevent this.
I don't believe that's true, can you tell us which code path(s) could trigger this because I didn't find one the 2min I spent reading the code.
No error path taken before line 563, ret is still not assigned to.
remaining == 0 which could come from being passed 0 on the command line, line 518, unless there is a check for that that I missed? Code reaches line 591 without assigning to ret.
Andrew
Quoted 7 lines
Quoted 2 lines
This issue was found by Smatch.
Seems like a false positive to me?
Cheers,
Quentin
Quentin Schulz
Reviewed-byHi Andrew,
Quoted 8 lines · Andrew Goodbody
Quoted 7 lines · Quentin Schulz
Hi Andrew,
Quoted 3 lines · Andrew Goodbody
ret maybe used uninitialised in some cases so instead initialise it first to prevent this.
Quoted 6 lines
Quoted 1 line
I don't believe that's true, can you tell us which code path(s) could trigger this because I didn't find one the 2min I spent reading the code.
No error path taken before line 563, ret is still not assigned to.
remaining == 0 which could come from being passed 0 on the command line, line 518, unless there is a check for that that I missed? Code reaches line 591 without assigning to ret.
Indeed, clearly missed that!
Thanks!
Quentin
Quoted 18 lines · Quentin Schulz
Hi Andrew,
Quoted 8 lines · Andrew Goodbody
Quoted 7 lines · Quentin Schulz
Hi Andrew,
Quoted 3 lines · Andrew Goodbody
ret maybe used uninitialised in some cases so instead initialise it first to prevent this.
Quoted 6 lines
Quoted 1 line
I don't believe that's true, can you tell us which code path(s) could trigger this because I didn't find one the 2min I spent reading the code.
No error path taken before line 563, ret is still not assigned to.
remaining == 0 which could come from being passed 0 on the command line, line 518, unless there is a check for that that I missed? Code reaches line 591 without assigning to ret.
Quoted 6 lines
Indeed, clearly missed that!
Reviewed-by Quentin Schulz <[email protected]>Thanks!
Quentin
Is there anything else needed before this can be merged please?
Thanks,
Andrew
ping?
Quoted 30 lines · Andrew Goodbody
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 <[email protected]>--- cmd/mtd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cmd/mtd.c +1
-2@@ -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-bb1ae86f33aaBest regards,
Quoted 6 lines · Andrew Goodbody
ret maybe used uninitialised in some cases so instead initialise it first to prevent this.
This issue was found by Smatch.
Applied to u-boot/master, thanks!
[1/1] cmd: mtd: Prevent use of uninitialised variable
commit: ce1bdedd2f4b3c5c8c76fbf2fc1a234fca470573
Signature · 1 line
Tom