[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <38eec5be-817a-4701-bd01-e747217bc44e@linux.intel.com>
Date: Sun, 28 Sep 2025 14:45:07 +0800
From: "Mi, Dapeng" <dapeng1.mi@...ux.intel.com>
To: Joey Pabalinas <joeypabalinas@...il.com>, linux-kernel@...r.kernel.org
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...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>,
Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH] perf/x86/amd/uncore: use kcalloc() instead of
multiplication
On 9/13/2025 2:35 PM, Joey Pabalinas wrote:
> Dynamic size calculations should not be performed in allocator
> function arguments due to overflow risk.
>
> Use kcalloc() instead of multiplication in the first argument
> of kzalloc().
>
> Signed-off-by: Joey Pabalinas <joeypabalinas@...il.com>
> ---
> arch/x86/events/amd/uncore.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
> index e8b6af199c738eb00b..d08e3054461f2ca07a 100644
> --- a/arch/x86/events/amd/uncore.c
> +++ b/arch/x86/events/amd/uncore.c
> @@ -1036,11 +1036,11 @@ int amd_uncore_umc_ctx_init(struct amd_uncore *uncore, unsigned int cpu)
> group_num_pmus[gid] = hweight32(info.split.aux_data);
> group_num_pmcs[gid] = info.split.num_pmcs;
> uncore->num_pmus += group_num_pmus[gid];
> }
>
> - uncore->pmus = kzalloc(sizeof(*uncore->pmus) * uncore->num_pmus,
> + uncore->pmus = kcalloc(uncore->num_pmus, sizeof(*uncore->pmus),
> GFP_KERNEL);
> if (!uncore->pmus) {
> uncore->num_pmus = 0;
> goto done;
> }
LGTM.
Reviewed-by: Dapeng Mi <dapeng1.mi@...ux.intel.com>
Powered by blists - more mailing lists