Re: [PATCH] perf iostat: Release the port list if command allocation fails

From: Namhyung Kim

Date: Mon Nov 09 2026 - 00:05:43 EST


Hello,

On Fri, Nov 06, 2026 at 10:18:40AM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@xxxxxxxxx>
>
> The event-group builder takes ownership of the root port list and frees
> it on its normal and parsing-error paths. If allocation of the event
> command fails, however, it returns directly without releasing the list,
> its pointer array or its ports.
>
> Use the existing cleanup path for this allocation failure too, before
> any port has been transferred to an event.
>
> Found while testing the iostat fixes with allocation fault injection.
>
> Fixes: f9ed693e8bc0 ("perf stat: Enable iostat mode for x86 platforms")
> Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>

This patch doesn't apply. Can you please rebase onto the current
perf-tools-next?

Thanks,
Namhyung

> ---
> tools/perf/arch/x86/util/iostat.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c
> index 2dc5ac6..f8b4939 100644
> --- a/tools/perf/arch/x86/util/iostat.c
> +++ b/tools/perf/arch/x86/util/iostat.c
> @@ -342,8 +342,10 @@ static int iostat_event_group(struct evlist *evl,
> struct perf_cpu cpu;
> unsigned int cpu_map_idx;
>
> - if (!iostat_cmd)
> - return -ENOMEM;
> + if (!iostat_cmd) {
> + ret = -ENOMEM;
> + goto err;
> + }
>
> for (idx = 0; idx < list->nr_entries; idx++) {
> sprintf(iostat_cmd, iostat_cmd_template,
> --
> 2.9.4
>