summaryrefslogtreecommitdiffstats
path: root/common/bootargs.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-01-26 21:16:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-26 21:16:41 +0100
commitecf2350530f45fefe7bab75dc63ccf56a539e8b7 (patch)
tree1d7bf320127dde44a0ab8dea7866908b10efcad7 /common/bootargs.c
parent01811d0d7209332aa7ba90acc2dba9b7b2c0067d (diff)
downloadbarebox-ecf2350530f45fefe7bab75dc63ccf56a539e8b7.tar.gz
bootargs: Fix memory leak in linux_bootargs_get()
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>
Diffstat (limited to 'common/bootargs.c')
-rw-r--r--common/bootargs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/common/bootargs.c b/common/bootargs.c
index a89f23a..f0ab689 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;
}