]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
boot: pxe: Prevent evaluation of uninitialised variable
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Mon, 30 Jun 2025 11:57:10 +0000 (12:57 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 9 Jul 2025 00:15:20 +0000 (18:15 -0600)
In the case where parse_sliteral returns an error then label_name
will not have been assigned to. In order to prevent evaluating
label_name in this case add a check for the return value of parse_sliteral.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
boot/pxe_utils.c

index 82f217aaf865e62b40234d5bfc2a067852a72c71..eb4d772348101f6b893b9ff3d35e30ef46bfa71d 100644 (file)
@@ -1348,7 +1348,7 @@ static int parse_pxefile_top(struct pxe_context *ctx, char *p, unsigned long bas
                case T_ONTIMEOUT:
                        err = parse_sliteral(&p, &label_name);
 
-                       if (label_name) {
+                       if (err >= 0 && label_name) {
                                if (cfg->default_label)
                                        free(cfg->default_label);
 
@@ -1360,7 +1360,7 @@ static int parse_pxefile_top(struct pxe_context *ctx, char *p, unsigned long bas
                case T_FALLBACK:
                        err = parse_sliteral(&p, &label_name);
 
-                       if (label_name) {
+                       if (err >= 0 && label_name) {
                                if (cfg->fallback_label)
                                        free(cfg->fallback_label);