diff options
author | Youling Tang <tangyouling@loongson.cn> | 2020-09-12 09:39:49 +0800 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2020-09-29 18:14:33 +0200 |
commit | 9fd2189baf7adc85f8017145e789d3256f6fcd24 (patch) | |
tree | 0a14b91de8eccb86bfa509512be40c5a7b869ee3 /kexec | |
parent | ec537918a32564789dad14e32389afb2991d7f8d (diff) |
kexec-tools: Add some missing free() calls
Add some missing free() calls.
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r-- | kexec/arch/i386/crashdump-x86.c | 22 | ||||
-rw-r--r-- | kexec/arch/mips/crashdump-mips.c | 5 | ||||
-rw-r--r-- | kexec/arch/ppc64/crashdump-ppc64.c | 8 |
3 files changed, 27 insertions, 8 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index c79791f..d5b5b68 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -913,8 +913,11 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, add_memmap(memmap_p, &nr_memmap, info->backup_src_start, info->backup_src_size, RANGE_RAM); for (i = 0; i < crash_reserved_mem_nr; i++) { sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1; - if (add_memmap(memmap_p, &nr_memmap, crash_reserved_mem[i].start, sz, RANGE_RAM) < 0) + if (add_memmap(memmap_p, &nr_memmap, crash_reserved_mem[i].start, + sz, RANGE_RAM) < 0) { + free(memmap_p); return ENOCRASHKERNEL; + } } /* Create a backup region segment to store backup data*/ @@ -926,22 +929,29 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, 0, max_addr, -1); dbgprintf("Created backup segment at 0x%lx\n", info->backup_start); - if (delete_memmap(memmap_p, &nr_memmap, info->backup_start, sz) < 0) + if (delete_memmap(memmap_p, &nr_memmap, info->backup_start, sz) < 0) { + free(tmp); + free(memmap_p); return EFAILED; + } } /* Create elf header segment and store crash image data. */ if (arch_options.core_header_type == CORE_TYPE_ELF64) { if (crash_create_elf64_headers(info, &elf_info, mem_range, nr_ranges, &tmp, &bufsz, - ELF_CORE_HEADER_ALIGN) < 0) + ELF_CORE_HEADER_ALIGN) < 0) { + free(memmap_p); return EFAILED; + } } else { if (crash_create_elf32_headers(info, &elf_info, mem_range, nr_ranges, &tmp, &bufsz, - ELF_CORE_HEADER_ALIGN) < 0) + ELF_CORE_HEADER_ALIGN) < 0) { + free(memmap_p); return EFAILED; + } } /* the size of the elf headers allocated is returned in 'bufsz' */ @@ -962,8 +972,10 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, elfcorehdr = add_buffer(info, tmp, bufsz, memsz, align, min_base, max_addr, -1); dbgprintf("Created elf header segment at 0x%lx\n", elfcorehdr); - if (delete_memmap(memmap_p, &nr_memmap, elfcorehdr, memsz) < 0) + if (delete_memmap(memmap_p, &nr_memmap, elfcorehdr, memsz) < 0) { + free(memmap_p); return -1; + } if (!bzImage_support_efi_boot || arch_options.noefi || !sysfs_efi_runtime_map_exist()) cmdline_add_efi(mod_cmdline); diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c index 26d5043..a135386 100644 --- a/kexec/arch/mips/crashdump-mips.c +++ b/kexec/arch/mips/crashdump-mips.c @@ -360,8 +360,11 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, crash_reserved_mem.end, -1); if (crash_create(info, elf_info, crash_memory_range, nr_ranges, - &tmp, &sz, ELF_CORE_HEADER_ALIGN) < 0) + &tmp, &sz, ELF_CORE_HEADER_ALIGN) < 0) { + free(tmp); return -1; + } + elfcorehdr = add_buffer(info, tmp, sz, sz, align, crash_reserved_mem.start, crash_reserved_mem.end, -1); diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c index b2787d5..26f9a01 100644 --- a/kexec/arch/ppc64/crashdump-ppc64.c +++ b/kexec/arch/ppc64/crashdump-ppc64.c @@ -535,15 +535,19 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, if (crash_create_elf64_headers(info, &elf_info64, crash_memory_range, nr_ranges, &tmp, &sz, - ELF_CORE_HEADER_ALIGN) < 0) + ELF_CORE_HEADER_ALIGN) < 0) { + free (tmp); return -1; + } } else { if (crash_create_elf32_headers(info, &elf_info32, crash_memory_range, nr_ranges, &tmp, &sz, - ELF_CORE_HEADER_ALIGN) < 0) + ELF_CORE_HEADER_ALIGN) < 0) { + free(tmp); return -1; + } } elfcorehdr = add_buffer(info, tmp, sz, sz, align, min_base, |