Skip to contentSkip to conversation

boot: pxe: Prevent evaluation of uninitialised variable

PATCH In review Andrew Goodbody 2 participants 2 messages Jun 30, 2025 – Jul 9, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot: pxe: Prevent evaluation of uninitialised variable

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.

---
 boot/pxe_utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
boot/pxe_utils.c +2 -2
index 82f217aaf86..eb4d7723481 100644
@@ -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);
 

---
base-commit: 7027b445cc0bfb86204ecb1f1fe596f5895048d9
change-id: 20250630-boot_pxe_fix-7877ae1f4cd6

Best regards,

Signature · 1 line
Andrew Goodbody <[email protected]>
#1 lore raw
Quoted 5 lines · Andrew Goodbody

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.

Applied to u-boot/master, thanks!

[1/1] boot: pxe: Prevent evaluation of uninitialised variable

      commit: c3b43eeaead77beef53a224c7d13346a0462b34d
Signature · 1 line
Tom