From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1efB4D-0005EA-GP for barebox@lists.infradead.org; Fri, 26 Jan 2018 20:57:47 +0000 From: Sascha Hauer Date: Fri, 26 Jan 2018 21:57:31 +0100 Message-Id: <20180126205731.29443-1-s.hauer@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] bootargs: Fix memory leak in linux_bootargs_get() 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 --- 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