]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: sysboot: null check filename
authorCaleb Connolly <caleb.connolly@linaro.org>
Mon, 18 Mar 2024 23:16:36 +0000 (23:16 +0000)
committerTom Rini <trini@konsulko.com>
Wed, 10 Apr 2024 15:26:00 +0000 (09:26 -0600)
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

index 63a7806debe4b058217adcc035ba8af5f1951a32..d14c570d96ab090de1158216040d79c77832fc03 100644 (file)
@@ -77,6 +77,10 @@ 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);