Commit 908d50e5 authored by Li Huafei's avatar Li Huafei Committed by Namhyung Kim
Browse files

perf disasm: Use disasm_line__free() to properly free disasm_line



symbol__disassemble_capstone_powerpc() goto the 'err' label when it
failed in the loop that created disasm_line, and then used free()
directly to free disasm_line. Since the structure disasm_line contains
members that allocate memory dynamically, this can result in a memory
leak. In fact, we can simply break the loop when it fails in the middle
of the loop, and disasm_line__free() will then be called to properly
free the created line. Other error paths do not need to consider freeing
disasm_line.

Fixes: c5d60de1 ("perf annotate: Add support to use libcapstone in powerpc")
Signed-off-by: default avatarLi Huafei <lihuafei1@huawei.com>
Tested-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: sesse@google.com
Cc: kjain@linux.ibm.com
Link: https://lore.kernel.org/r/20241019154157.282038-2-lihuafei1@huawei.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent b4e0e9a1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment