Skip to contentSkip to conversation

cmd: sysboot: null check filename

PATCH In review Caleb Connolly 2 participants 2 messages Mar 18, 2024 – Apr 10, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: sysboot: null check filename

Currently if ${bootfile} is unset and sysboot is invoked with no filename specified then U-Boot will crash will a null-pointer dereference. Add the missing check and a matching error print.

Fixes 993c912d304d ("cmd: sysboot: Create a sysboot command dedicated file")
---
 cmd/sysboot.c | 4 ++++
 1 file changed, 4 insertions(+)
cmd/sysboot.c +4 -0
index 63a7806debe4..d14c570d96ab 100644
@@ -76,8 +76,12 @@ static int do_sysboot(struct cmd_tbl *cmdtp, int flag, int argc,
 	}
 
 	if (argc < 6) {
 		filename = env_get("bootfile");
+		if (!filename) {
+			printf("Specify a filename or set the ${bootfile} environment variable\n");
+			return 1;
+		}
 	} else {
 		filename = argv[5];
 		env_set("bootfile", filename);
 	}
Signature · 1 line
2.44.0
#1 lore raw
Quoted 5 lines · Caleb Connolly

Currently if ${bootfile} is unset and sysboot is invoked with no filename specified then U-Boot will crash will a null-pointer dereference. Add the missing check and a matching error print.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom