elf2dmp: free memory in failure
authorlu zhipeng <luzhipeng@cestc.cn>
Fri, 7 Oct 2022 02:01:28 +0000 (10:01 +0800)
committerLaurent Vivier <laurent@vivier.eu>
Sat, 22 Oct 2022 21:10:03 +0000 (23:10 +0200)
The 'kdgb' is allocating memory in get_kdbg(), but it is not freed in
error path. So fix that.

Signed-off-by: lu zhipeng <luzhipeng@cestc.cn>
Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20221007020128.760-1-luzhipeng@cestc.cn>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
contrib/elf2dmp/main.c

index b9fc6d230ca04c68d490a9288af34076b288de40..d77b8f98f78d8b6d6eff8c915f5fee572d5f2ca3 100644 (file)
@@ -125,6 +125,7 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb,
 
     if (va_space_rw(vs, KdDebuggerDataBlock, kdbg, kdbg_hdr.Size, 0)) {
         eprintf("Failed to extract entire KDBG\n");
+        free(kdbg);
         return NULL;
     }