[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250624194350.109790-2-alok.a.tiwari@oracle.com>
Date: Tue, 24 Jun 2025 12:43:38 -0700
From: Alok Tiwari <alok.a.tiwari@...cle.com>
To: jonathan.cameron@...wei.com, will@...nel.org, mark.rutland@....com,
linux-cxl@...r.kernel.org
Cc: alok.a.tiwari@...cle.com, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 1/3] perf/cxlpmu: Fix devm_kcalloc() argument order in cxl_pmu_probe()
The previous code mistakenly swapped the count and size parameters.
This fix corrects the argument order in devm_kcalloc() to follow the
conventional count, size form, avoiding potential confusion or bugs.
Previous usage:
devm_kcalloc(dev, sizeof(*info->hw_events), info->num_counters,
GFP_KERNEL);
New usage:
devm_kcalloc(dev, info->num_counters, sizeof(*info->hw_events),
GFP_KERNEL);
Previous incorrect order could lead to unexpected memory allocation
behavior. This fix ensures correct allocation of hw_event structure.
Signed-off-by: Alok Tiwari <alok.a.tiwari@...cle.com>
---
drivers/perf/cxl_pmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/perf/cxl_pmu.c b/drivers/perf/cxl_pmu.c
index d6693519eaee2..8998c0a2f3a2d 100644
--- a/drivers/perf/cxl_pmu.c
+++ b/drivers/perf/cxl_pmu.c
@@ -834,8 +834,8 @@ static int cxl_pmu_probe(struct device *dev)
if (rc)
return rc;
- info->hw_events = devm_kcalloc(dev, sizeof(*info->hw_events),
- info->num_counters, GFP_KERNEL);
+ info->hw_events = devm_kcalloc(dev, info->num_counters,
+ sizeof(*info->hw_events), GFP_KERNEL);
if (!info->hw_events)
return -ENOMEM;
--
2.46.0
Powered by blists - more mailing lists