From: Zhang Yanfei <[email protected]>

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 <[email protected]>
---
 kexec/kexec.c |    8 +++++---
 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)
-- 
1.7.1

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to