* [PATCH] perf iostat: Release the port list if command allocation fails
@ 2026-11-06 2:18 lirongqing
2026-11-09 5:05 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-11-06 2:18 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark, Li RongQing,
Alexander Antonov, linux-perf-users, linux-kernel
From: Li RongQing <lirongqing@baidu.com>
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@baidu.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] perf iostat: Release the port list if command allocation fails
2026-11-06 2:18 [PATCH] perf iostat: Release the port list if command allocation fails lirongqing
@ 2026-11-09 5:05 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2026-11-09 5:05 UTC (permalink / raw)
To: lirongqing
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, James Clark, Alexander Antonov, linux-perf-users,
linux-kernel
Hello,
On Fri, Nov 06, 2026 at 10:18:40AM +0800, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> 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@baidu.com>
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-09 5:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 2:18 [PATCH] perf iostat: Release the port list if command allocation fails lirongqing
2026-11-09 5:05 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®