summaryrefslogtreecommitdiff
path: root/kexec/kexec.c
diff options
context:
space:
mode:
authorZhang Yanfei <zhangyanfei@cn.fujitsu.com>2013-03-25 23:03:52 +0800
committerSimon Horman <horms@verge.net.au>2013-03-27 21:34:58 +0900
commit3a33a6089b2434aafb1ea1894bd342b507faab9d (patch)
treebef596876260ec31d3ee1ba1d3375155bc6a13f5 /kexec/kexec.c
parentfa101c374d69597bb228d1f1230b2d37ba888db3 (diff)
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 <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/kexec.c')
-rw-r--r--kexec/kexec.c8
1 files changed, 5 insertions, 3 deletions
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)