diff mbox series

cmd: sysboot: null check filename

Message ID 20240318231640.1343956-1-caleb.connolly@linaro.org
State Accepted
Commit ae8e1d5aa46034963bca28fb07dac76970f718fe
Headers show
Series cmd: sysboot: null check filename | expand

Commit Message

Caleb Connolly March 18, 2024, 11:16 p.m. UTC
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")
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 cmd/sysboot.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Tom Rini April 10, 2024, 5:43 p.m. UTC | #1
On Mon, 18 Mar 2024 23:16:36 +0000, Caleb Connolly wrote:

> 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!
diff mbox series

Patch

diff --git a/cmd/sysboot.c b/cmd/sysboot.c
index 63a7806debe4..d14c570d96ab 100644
--- a/cmd/sysboot.c
+++ b/cmd/sysboot.c
@@ -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);
 	}