[PATCH] boot: pxe: Prevent evaluation of uninitialised variable

Andrew Goodbody andrew.goodbody at linaro.org
Mon Jun 30 13:57:10 CEST 2025


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 at linaro.org>
---
 boot/pxe_utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 82f217aaf86..eb4d7723481 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -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,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list