bootm: Fix bootz, bmi->images pointer was uninitialized
PATCH 1/1 bootm: Fix bootz, bmi->images pointer was uninitialized
When building with only bootz command, without bootm, images pointer inside bootm_info structure is not initialized. And since this structure is stored in stack the generated error is kind of random, but most of the time this will generate: "ramdisk - allocation error"
--- boot/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
boot/bootm.c +1 -1
@@ -1169,7 +1169,7 @@ void bootm_init(struct bootm_info *bmi) {memset (bmi,'\0' ,sizeof (struct bootm_info )); bmi->boot_progress = true; -if (IS_ENABLED (CONFIG_CMD_BOOTM )) +if (IS_ENABLED (CONFIG_CMD_BOOTM ) ||IS_ENABLED (CONFIG_CMD_BOOTZ )) bmi->images = &images; }
Signature · 1 line
2.49.0
Quoted 15 lines · Benjamin ROBIN
When building with only bootz command, without bootm, images pointer inside
bootm_infostructure is not initialized. And since this structure is stored in stack the generated error is kind of random, but most of the time this will generate: "ramdisk - allocation error"Signed-off-by Benjamin ROBIN <[email protected]>--- boot/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)boot/bootm.c +0
-0
boot/bootm.c void bootm_init(struct bootm_info *bmi) · line 1174
Quoted 7 lines
boot/bootm.c +1
-1@@ -1169,7 +1169,7 @@ void bootm_init(struct bootm_info *bmi) {memset (bmi,'\0' ,sizeof (struct bootm_info )); bmi->boot_progress = true; -if (IS_ENABLED (CONFIG_CMD_BOOTM )) +if (IS_ENABLED (CONFIG_CMD_BOOTM ) ||IS_ENABLED (CONFIG_CMD_BOOTZ )) bmi->images = &images; }
Good catch. This should also get a:
And after reading the code and grepping around more, I think we should be doing the assignment unconditionally in the function. It's what we practically do today as only colibri_vf disables CMD_BOOTM but then also enables any other OS boot command.
Signature · 1 line
Tom
Quoted 2 lines · Tom Rini
Good catch. This should also get a:
Fixes c2211ff65136 ("bootm: Add more fields to bootm_info")
Thank you for the review.
I am preparing a v2 of this patch.
Quoted 6 lines
And after reading the code and grepping around more, I think we should be doing the assignment unconditionally in the function. It's what we practically do today as only
colibri_vfdisablesCMD_BOOTMbut then also enables any other OS boot command.Signature · 1 line
Tom
I did a bit more analysis, I put my discoveries into the commit message of the second version of this patch. And yes, you are right, the assignment should be done unconditionally (as I understand it).
Benjamin