From: Markus Elfring <Markus.Elfring@web.de>
To: linux-perf-users@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>, Ingo Molnar <mingo@redhat.com>,
James Clark <james.clark@linaro.org>,
Jiri Olsa <jolsa@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Gaosheng Cui <cuigaosheng1@huawei.com>,
Jing Zhang <renyu.zj@linux.alibaba.com>,
John Garry <john.g.garry@oracle.com>,
Kajol Jain <kjain@linux.ibm.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
Rob Herring <robh@kernel.org>
Subject: [PATCH] perf pmu: Improve exception handling in perf_pmu__lookup()
Date: Tue, 4 Mar 2025 13:13:20 +0100 [thread overview]
Message-ID: <5b73ab68-fab6-417a-a410-69efc1f7b97b@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Mar 2025 12:55:05 +0100
A zfree() call is not helpful after a failed strdup(name) call in
this function implementation.
Thus use an other jump target instead.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
tools/perf/util/pmu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 57450c73fb63..74eb46390233 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1107,7 +1107,7 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
pmu->name = strdup(name);
if (!pmu->name)
- goto err;
+ goto free_pmu;
/*
* Read type early to fail fast if a lookup name isn't a PMU. Ensure
@@ -1155,6 +1155,7 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
return pmu;
err:
zfree(&pmu->name);
+free_pmu:
free(pmu);
return NULL;
}
--
2.48.1
reply other threads:[~2025-03-04 12:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=5b73ab68-fab6-417a-a410-69efc1f7b97b@web.de \
--to=markus.elfring@web.de \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=cuigaosheng1@huawei.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kjain@linux.ibm.com \
--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 \
--cc=ravi.bangoria@amd.com \
--cc=renyu.zj@linux.alibaba.com \
--cc=robh@kernel.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®