mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] bootargs: Fix memory leak in linux_bootargs_get()
@ 2018-01-26 20:57 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2018-01-26 20:57 UTC (permalink / raw)
  To: Barebox List

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-01-26 20:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26 20:57 [PATCH] bootargs: Fix memory leak in linux_bootargs_get() Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox