diff options
author | Zhang Yanfei <zhangyanfei@cn.fujitsu.com> | 2013-03-25 23:16:34 +0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2013-03-27 21:41:49 +0900 |
commit | a99e54d0f6334e5e5b4713b7a7dd865d903f23fc (patch) | |
tree | 9e18a5473339d0249317c0edf93524af599b7b85 /kexec | |
parent | c8bc3a8b369bbe748cbf13a7ccfc1848c4e1d563 (diff) |
kexec: x86_64: bzImage64: fix memory leak caused by get_command_line
Since get_command_line returns dynamically allocated memory, it is
easy for the caller to forget freeing the memory. Here fixes a
memory leak caused by this function.
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r-- | kexec/arch/x86_64/kexec-bzImage64.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c index 86e6d13..21bc4ae 100644 --- a/kexec/arch/x86_64/kexec-bzImage64.c +++ b/kexec/arch/x86_64/kexec-bzImage64.c @@ -232,7 +232,7 @@ static int do_bzImage64_load(struct kexec_info *info, int bzImage64_load(int argc, char **argv, const char *buf, off_t len, struct kexec_info *info) { - char *command_line = NULL; + char *command_line = NULL, *tmp_cmdline = NULL; const char *ramdisk = NULL, *append = NULL; char *ramdisk_buf; off_t ramdisk_length = 0; @@ -269,7 +269,7 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len, append = optarg; break; case OPT_REUSE_CMDLINE: - command_line = get_command_line(); + tmp_cmdline = get_command_line(); break; case OPT_RAMDISK: ramdisk = optarg; @@ -282,7 +282,9 @@ int bzImage64_load(int argc, char **argv, const char *buf, off_t len, break; } } - command_line = concat_cmdline(command_line, append); + command_line = concat_cmdline(tmp_cmdline, append); + if (tmp_cmdline) + free(tmp_cmdline); command_line_len = 0; if (command_line) command_line_len = strlen(command_line) + 1; |