[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2f180ed6-9cea-615d-638a-844ea154e9e1@huawei.com>
Date: Sat, 19 Oct 2024 10:44:17 +0800
From: Li Huafei <lihuafei1@...wei.com>
To: Namhyung Kim <namhyung@...nel.org>
CC: <atrajeev@...ux.vnet.ibm.com>, <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 3/3] perf disasm: Fix not cleaning up disasm_line in
symbol__disassemble_raw()
On 2024/10/18 6:20, Namhyung Kim wrote:
> On Mon, Oct 14, 2024 at 07:42:48PM +0800, Li Huafei wrote:
>> In symbol__disassemble_raw(), the created disasm_line should be
>> discarded before returning an error.
>
> But other error paths don't need to free the disasm_line because they
> failed before creating one. I think the simpler fix is to break the
> loop when it fails on disasm_line__new().
>
Yes, we only need to consider whether to release the created lines when
the loop fails in the middle. I will send a v2 version later.
Thanks,
Huafei
> Thanks,
> Namhyung
>
>>
>> Fixes: 0b971e6bf1c3 ("perf annotate: Add support to capture and parse raw instruction in powerpc using dso__data_read_offset utility")
>> Signed-off-by: Li Huafei <lihuafei1@...wei.com>
>> ---
>> tools/perf/util/disasm.c | 26 ++++++++++++--------------
>> 1 file changed, 12 insertions(+), 14 deletions(-)
>>
>> diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
>> index 40d99f4d5cc7..4e5becd5eca6 100644
>> --- a/tools/perf/util/disasm.c
>> +++ b/tools/perf/util/disasm.c
>> @@ -1774,25 +1774,23 @@ static int symbol__disassemble_raw(char *filename, struct symbol *sym,
>> 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:
>> free(buf);
>> return count < 0 ? count : 0;
>>
>> err:
>> + if (!list_empty(¬es->src->source)) {
>> + struct disasm_line *tmp;
>> +
>> + /*
>> + * It probably failed in the middle of the above loop.
>> + * Release any resources it might add.
>> + */
>> + list_for_each_entry_safe(dl, tmp, ¬es->src->source, al.node) {
>> + list_del(&dl->al.node);
>> + disasm_line__free(dl);
>> + }
>> + }
>> count = -1;
>> goto out;
>> }
>> --
>> 2.25.1
>>
> .
>
Powered by blists - more mailing lists