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

Signed-off-by: Sascha Hauer <[email protected]>
---
 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


Reply via email to