linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation
@ 2023-02-02  2:18 Zev Weiss
  2023-02-03  0:01 ` Winiarska, Iwona
  2023-02-03 15:27 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Zev Weiss @ 2023-02-02  2:18 UTC (permalink / raw)
  To: Iwona Winiarska, Guenter Roeck
  Cc: Zev Weiss, Greg Kroah-Hartman, Jae Hyun Yoo, Jean Delvare,
	Pierre-Louis Bossart, openbmc, linux-hwmon, linux-kernel, stable

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation
  2023-02-02  2:18 [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation Zev Weiss
@ 2023-02-03  0:01 ` Winiarska, Iwona
  2023-02-03 15:27 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Winiarska, Iwona @ 2023-02-03  0:01 UTC (permalink / raw)
  To: linux, zev
  Cc: linux-hwmon, jdelvare, gregkh, stable, linux-kernel,
	pierre-louis.bossart, jae.hyun.yoo, openbmc

On Wed, 2023-02-01 at 18:18 -0800, Zev Weiss wrote:
> 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")

Thanks for catching it.

Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>

> ---
>  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;
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation
  2023-02-02  2:18 [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation Zev Weiss
  2023-02-03  0:01 ` Winiarska, Iwona
@ 2023-02-03 15:27 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2023-02-03 15:27 UTC (permalink / raw)
  To: Zev Weiss
  Cc: Iwona Winiarska, Greg Kroah-Hartman, Jae Hyun Yoo, Jean Delvare,
	Pierre-Louis Bossart, openbmc, linux-hwmon, linux-kernel, stable

On Wed, Feb 01, 2023 at 06:18:25PM -0800, Zev Weiss wrote:
> 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")
> Reviewed-by: Iwona Winiarska <iwona.winiarska@intel.com>

Applied.

Thanks,
Guenter

> ---
>  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;
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-03 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02  2:18 [PATCH] hwmon: (peci/cputemp) Fix off-by-one in coretemp_label allocation Zev Weiss
2023-02-03  0:01 ` Winiarska, Iwona
2023-02-03 15:27 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).