public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 01/13] kexec: fix possible memory leak in check_reuse_initrd
@ 2013-03-25 15:03 Zhang Yanfei
  2013-03-25 15:05 ` [PATCH 02/13] kexec: i386: bzImage: fix memory leak caused by get_command_line Zhang Yanfei
                   ` (11 more replies)
  0 siblings, 12 replies; 26+ messages in thread
From: Zhang Yanfei @ 2013-03-25 15:03 UTC (permalink / raw)
  To: Simon Horman; +Cc: kexec@lists.infradead.org

From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>

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>
---
 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
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-03-27 12:42 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-25 15:03 [PATCH 01/13] kexec: fix possible memory leak in check_reuse_initrd Zhang Yanfei
2013-03-25 15:05 ` [PATCH 02/13] kexec: i386: bzImage: fix memory leak caused by get_command_line Zhang Yanfei
2013-03-27 12:36   ` Simon Horman
2013-03-25 15:07 ` [PATCH 03/13] kexec: i386: elf: fix possible memory leak in elf_x86_load Zhang Yanfei
2013-03-25 15:09   ` [PATCH 04/13] kexec: i386: elf: fix memory leak caused by get_command_line Zhang Yanfei
2013-03-27 12:37     ` Simon Horman
2013-03-27 12:36   ` [PATCH 03/13] kexec: i386: elf: fix possible memory leak in elf_x86_load Simon Horman
2013-03-25 15:10 ` [PATCH 05/13] kexec: i386: multiboot: fix possible memory leak in multiboot_x86_load Zhang Yanfei
2013-03-27 12:38   ` Simon Horman
2013-03-25 15:11 ` [PATCH 06/13] kexec: i386: multiboot: fix memory leak caused by get_command_line Zhang Yanfei
2013-03-27 12:38   ` Simon Horman
2013-03-25 15:12 ` [PATCH 07/13] kexec: ppc: elf: fix possible memory leak in elf_ppc_load Zhang Yanfei
2013-03-27 12:40   ` Simon Horman
2013-03-25 15:13 ` [PATCH 08/13] kexec: ppc: elf: fix memory leak caused by get_command_line Zhang Yanfei
2013-03-27 12:40   ` Simon Horman
2013-03-25 15:15 ` [PATCH 09/13] kexec: ppc: uImage: fix possible memory leak in ppc_load_bare_bits Zhang Yanfei
2013-03-27 12:41   ` Simon Horman
2013-03-25 15:15 ` [PATCH 10/13] kexec: ppc: uImage: fix memory leak caused by get_command_line Zhang Yanfei
2013-03-27 12:41   ` Simon Horman
2013-03-25 15:16 ` [PATCH 11/13] kexec: x86_64: bzImage64: " Zhang Yanfei
2013-03-27 12:41   ` Simon Horman
2013-03-25 15:17 ` [PATCH 12/13] kexec: x86_64: elf: " Zhang Yanfei
2013-03-27 12:42   ` Simon Horman
2013-03-25 15:18 ` [PATCH 13/13] kexec: x86_64: elf: fix possible memory leak in elf_x86_64_load Zhang Yanfei
2013-03-27 12:42   ` Simon Horman
2013-03-27 12:35 ` [PATCH 01/13] kexec: fix possible memory leak in check_reuse_initrd Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox