[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <90BD7422-B738-4A35-8D45-51212E17716C@linux.vnet.ibm.com>
Date: Tue, 15 Oct 2024 19:25:29 +0530
From: Athira Rajeev <atrajeev@...ux.vnet.ibm.com>
To: Li Huafei <lihuafei1@...wei.com>
Cc: namhyung@...nel.org, peterz@...radead.org, mingo@...hat.com,
acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
irogers@...gle.com, adrian.hunter@...el.com, kan.liang@...ux.intel.com,
kjain@...ux.ibm.com, sesse@...gle.com,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] perf disasm: Use disasm_line__free() to properly free
disasm_line
> On 14 Oct 2024, at 5:12 PM, Li Huafei <lihuafei1@...wei.com> wrote:
>
> The structure disasm_line contains members that require dynamically
> allocated memory and need to be freed correctly using
> disasm_line__free().
>
> This patch fixes the incorrect freeing in
> symbol__disassemble_capstone_powerpc(). Also, since cs_disasm is not
> enabled, it does not need to handle the situation described in
> symbol__disassemble_capstone() where "offset != len" may occur due to
> unknown instructions.
>
> Fixes: c5d60de1813a ("perf annotate: Add support to use libcapstone in powerpc")
> Signed-off-by: Li Huafei <lihuafei1@...wei.com>
For the patches
Tested-by: Athira Rajeev <atrajeev@...ux.vnet.ibm.com <mailto:atrajeev@...ux.vnet.ibm.com>>
Thanks
Athira
> ---
> tools/perf/util/disasm.c | 16 +---------------
> 1 file changed, 1 insertion(+), 15 deletions(-)
>
> diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
> index 42222d61ceb5..40d99f4d5cc7 100644
> --- a/tools/perf/util/disasm.c
> +++ b/tools/perf/util/disasm.c
> @@ -1580,20 +1580,6 @@ static int symbol__disassemble_capstone_powerpc(char *filename, struct symbol *s
> offset += 4;
> }
>
> - /* It failed in the middle */
> - if (offset != len) {
> - struct list_head *list = ¬es->src->source;
> -
> - /* Discard all lines and fallback to objdump */
> - while (!list_empty(list)) {
> - dl = list_first_entry(list, struct disasm_line, al.node);
> -
> - list_del_init(&dl->al.node);
> - disasm_line__free(dl);
> - }
> - count = -1;
> - }
> -
> out:
> if (needs_cs_close)
> cs_close(&handle);
> @@ -1612,7 +1598,7 @@ static int symbol__disassemble_capstone_powerpc(char *filename, struct symbol *s
> */
> list_for_each_entry_safe(dl, tmp, ¬es->src->source, al.node) {
> list_del(&dl->al.node);
> - free(dl);
> + disasm_line__free(dl);
> }
> }
> count = -1;
> --
> 2.25.1
>
Powered by blists - more mailing lists