[PATCH] bootargs: Fix memory leak in linux_bootargs_get()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux