[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aJ-aDh8RG4CXcnI4@google.com>
Date: Fri, 15 Aug 2025 13:35:26 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Miaoqian Lin <linmq006@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
James Clark <james.clark@...aro.org>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] perf: pmu: Fix IS_ERR() vs NULL check bug in
perf_pmu__init
Hello,
On Tue, Aug 05, 2025 at 10:32:07AM +0400, Miaoqian Lin wrote:
> Replace NULL check with IS_ERR() check after calling
> hashmap__new() since this function return error pointers (ERR_PTR).
> Using NULL check could lead to invalid pointer dereference.
>
> Fixes: 754baf426e09 ("perf pmu: Change aliases from list to hashmap")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
Acked-by: Namhyung Kim <namhyung@...nel.org>
Thanks,
Namhyung
> ---
> tools/perf/util/pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 5a291f1380ed..da6f05872493 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1176,7 +1176,7 @@ int perf_pmu__init(struct perf_pmu *pmu, __u32 type, const char *name)
> return -ENOMEM;
>
> pmu->aliases = hashmap__new(aliases__hash, aliases__equal, /*ctx=*/ NULL);
> - if (!pmu->aliases)
> + if (IS_ERR(pmu->aliases))
> return -ENOMEM;
>
> return 0;
> --
> 2.25.1
>
Powered by blists - more mailing lists