From: Zev Weiss <zev@bewilderbeest.net>
To: Iwona Winiarska <iwona.winiarska@intel.com>,
Guenter Roeck <linux@roeck-us.net>
Cc: Zev Weiss <zev@bewilderbeest.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>,
Jean Delvare <jdelvare@suse.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
openbmc@lists.ozlabs.org, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@kernel.org
Subject: [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation
Date: Wed, 1 Feb 2023 18:18:25 -0800 [thread overview]
Message-ID: <20230202021825.21486-1-zev@bewilderbeest.net> (raw)
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@bewilderbeest.net>
Cc: stable@kernel.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
next reply other threads:[~2023-02-02 2:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 2:18 Zev Weiss [this message]
2023-02-03 0:01 ` Winiarska, Iwona
2023-02-03 15:27 ` Guenter Roeck
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=20230202021825.21486-1-zev@bewilderbeest.net \
--to=zev@bewilderbeest.net \
--cc=gregkh@linuxfoundation.org \
--cc=iwona.winiarska@intel.com \
--cc=jae.hyun.yoo@linux.intel.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=openbmc@lists.ozlabs.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=stable@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®