From: lirongqing <lirongqing@baidu.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Li RongQing <lirongqing@baidu.com>,
Alexander Antonov <alexander.antonov@linux.intel.com>,
<linux-perf-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] perf iostat: Release the port list if command allocation fails
Date: Fri, 6 Nov 2026 10:18:40 +0800 [thread overview]
Message-ID: <20261106021840.2186-1-lirongqing@baidu.com> (raw)
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
next reply other threads:[~2026-11-06 2:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 2:18 lirongqing [this message]
2026-11-09 5:05 ` Namhyung Kim
2026-11-09 5:18 ` 答复: [外部邮件] " Li,Rongqing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106021840.2186-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.antonov@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®