Skip to content

Commit 554a880

Browse files
tiwaigregkh
authored andcommitted
x86/kexec: Fix double-free of elf header buffer
commit d00dd2f upstream. After b3e34a4 ("x86/kexec: fix memory leak of elf header buffer"), freeing image->elf_headers in the error path of crash_load_segments() is not needed because kimage_file_post_load_cleanup() will take care of that later. And not clearing it could result in a double-free. Drop the superfluous vfree() call at the error path of crash_load_segments(). Fixes: b3e34a4 ("x86/kexec: fix memory leak of elf header buffer") Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Baoquan He <bhe@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: <stable@kernel.org> Link: https://lore.kernel.org/r/20221122115122.13937-1-tiwai@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 264241a commit 554a880

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

arch/x86/kernel/crash.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ int crash_load_segments(struct kimage *image)
401401
kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
402402
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
403403
ret = kexec_add_buffer(&kbuf);
404-
if (ret) {
405-
vfree((void *)image->elf_headers);
404+
if (ret)
406405
return ret;
407-
}
408406
image->elf_load_addr = kbuf.mem;
409407
pr_debug("Loaded ELF headers at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
410408
image->elf_load_addr, kbuf.bufsz, kbuf.bufsz);

0 commit comments

Comments
 (0)