[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 1 Feb 2023 18:18:25 -0800
From: Zev Weiss <zev@...ilderbeest.net>
To: Iwona Winiarska <iwona.winiarska@...el.com>,
Guenter Roeck <linux@...ck-us.net>
Cc: Zev Weiss <zev@...ilderbeest.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jae Hyun Yoo <jae.hyun.yoo@...ux.intel.com>,
Jean Delvare <jdelvare@...e.com>,
Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
openbmc@...ts.ozlabs.org, linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...nel.org
Subject: [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation
The find_last_bit() call produces the index of the highest-numbered
core in core_mask; because cores are numbered from zero, the number of
elements we need to allocate is one more than that.
Signed-off-by: Zev Weiss <zev@...ilderbeest.net>
Cc: stable@...nel.org # v5.18
Fixes: bf3608f338e9 ("hwmon: peci: Add cputemp driver")
---
drivers/hwmon/peci/cputemp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c
index ec9851daf2e8..f13cc4170f58 100644
--- a/drivers/hwmon/peci/cputemp.c
+++ b/drivers/hwmon/peci/cputemp.c
@@ -431,7 +431,7 @@ static int create_temp_label(struct peci_cputemp *priv)
unsigned long core_max = find_last_bit(priv->core_mask, CORE_NUMS_MAX);
int i;
- priv->coretemp_label = devm_kzalloc(priv->dev, core_max * sizeof(char *), GFP_KERNEL);
+ priv->coretemp_label = devm_kzalloc(priv->dev, (core_max + 1) * sizeof(char *), GFP_KERNEL);
if (!priv->coretemp_label)
return -ENOMEM;
--
2.39.1.236.ga8a28b9eace8
Powered by blists - more mailing lists