From 3a33a6089b2434aafb1ea1894bd342b507faab9d Mon Sep 17 00:00:00 2001 From: Zhang Yanfei Date: Mon, 25 Mar 2013 23:03:52 +0800 Subject: kexec: fix possible memory leak in check_reuse_initrd If the if test is ok, then it will call die() to exit the process, so freeing line will not be reached, causing memory leak. Fix this. Signed-off-by: Zhang Yanfei Signed-off-by: Simon Horman --- kexec/kexec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'kexec') diff --git a/kexec/kexec.c b/kexec/kexec.c index f3928af..6575ada 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -1020,13 +1020,15 @@ char *get_command_line(void) /* check we retained the initrd */ static void check_reuse_initrd(void) { + char *str = NULL; char *line = get_command_line(); - if (strstr(line, "retain_initrd") == NULL) + str = strstr(line, "retain_initrd"); + free(line); + + if (str == NULL) die("unrecoverable error: current boot didn't " "retain the initrd for reuse.\n"); - - free(line); } char *concat_cmdline(const char *base, const char *append) -- cgit