[PATCH] bootargs: fix memory leak

Sascha Hauer s.hauer at pengutronix.de
Thu Nov 27 00:07:05 PST 2025


globalvar_get_match() returns an allocated string. Free it after usage,
even when the allocated string is empty.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/bootargs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/bootargs.c b/common/bootargs.c
index ad8007d32a..36528b8b58 100644
--- a/common/bootargs.c
+++ b/common/bootargs.c
@@ -34,8 +34,10 @@ const char *linux_bootargs_get(void)
 	free(linux_bootargs);
 
 	bootargs = globalvar_get_match("linux.bootargs.", " ");
-	if (!strlen(bootargs))
+	if (!strlen(bootargs)) {
+		free(bootargs);
 		return getenv("bootargs");
+	}
 
 	linux_bootargs = bootargs;
 
-- 
2.47.3




More information about the barebox mailing list