[PATCH] bootargs: Fix memory leak in linux_bootargs_get()
Sascha Hauer
s.hauer at pengutronix.de
Fri Jan 26 12:57:31 PST 2018
globalvar_get_match() returns an allocated string which may be
empty. We have to free() the empty string aswell.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
common/bootargs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/common/bootargs.c b/common/bootargs.c
index a89f23a3f2..f0ab689158 100644
--- a/common/bootargs.c
+++ b/common/bootargs.c
@@ -56,19 +56,21 @@ const char *linux_bootargs_get(void)
bootargs = basprintf("%s mtdparts=%s", linux_bootargs,
parts);
free(linux_bootargs);
- free(parts);
linux_bootargs = bootargs;
}
+ free(parts);
+
parts = globalvar_get_match("linux.blkdevparts.", ";");
if (strlen(parts)) {
bootargs = basprintf("%s blkdevparts=%s", linux_bootargs,
parts);
free(linux_bootargs);
- free(parts);
linux_bootargs = bootargs;
}
+ free(parts);
+
return linux_bootargs;
}
--
2.15.1
More information about the barebox
mailing list