linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH hwmon-next 1/1] hwmon: (mlxreg-fan) Fix defect reported by Coverity Scan for linux-next
@ 2021-09-20 17:41 Vadim Pasternak
  2021-09-24  1:09 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Vadim Pasternak @ 2021-09-20 17:41 UTC (permalink / raw)
  To: linux; +Cc: linux-hwmon, Vadim Pasternak

Fix counter limit in 'for' loop in mlxreg_fan_cooling_config().
The issue found in the report on new defect(s) introduced to linux-next
weekly scan found with Coverity Scan - memory access violation.

** CID 1507571:  Memory - illegal accesses  (OVERRUN)
/drivers/hwmon/mlxreg-fan.c: 560 in mlxreg_fan_cooling_config()

>>> Overrunning array of 160 bytes at byte offset 160 by dereferencing
	pointer "pwm".

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/hwmon/mlxreg-fan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
index 35228ed112d7..feab9ec6a6ca 100644
--- a/drivers/hwmon/mlxreg-fan.c
+++ b/drivers/hwmon/mlxreg-fan.c
@@ -554,7 +554,7 @@ static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan)
 {
 	int i, j;
 
-	for (i = 0; i <= MLXREG_FAN_MAX_PWM; i++) {
+	for (i = 0; i < MLXREG_FAN_MAX_PWM; i++) {
 		struct mlxreg_fan_pwm *pwm = &fan->pwm[i];
 
 		if (!pwm->connected)
-- 
2.20.1


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

* Re: [PATCH hwmon-next 1/1] hwmon: (mlxreg-fan) Fix defect reported by Coverity Scan for linux-next
  2021-09-20 17:41 [PATCH hwmon-next 1/1] hwmon: (mlxreg-fan) Fix defect reported by Coverity Scan for linux-next Vadim Pasternak
@ 2021-09-24  1:09 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-09-24  1:09 UTC (permalink / raw)
  To: Vadim Pasternak; +Cc: linux-hwmon

On Mon, Sep 20, 2021 at 08:41:18PM +0300, Vadim Pasternak wrote:
> Fix counter limit in 'for' loop in mlxreg_fan_cooling_config().
> The issue found in the report on new defect(s) introduced to linux-next
> weekly scan found with Coverity Scan - memory access violation.
> 
> ** CID 1507571:  Memory - illegal accesses  (OVERRUN)
> /drivers/hwmon/mlxreg-fan.c: 560 in mlxreg_fan_cooling_config()
> 
> >>> Overrunning array of 160 bytes at byte offset 160 by dereferencing
> 	pointer "pwm".
> 
> Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>

I just applied a similar patch. I added you as Reported-by: to that patch.

Thanks,
Guenter

> ---
>  drivers/hwmon/mlxreg-fan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
> index 35228ed112d7..feab9ec6a6ca 100644
> --- a/drivers/hwmon/mlxreg-fan.c
> +++ b/drivers/hwmon/mlxreg-fan.c
> @@ -554,7 +554,7 @@ static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan)
>  {
>  	int i, j;
>  
> -	for (i = 0; i <= MLXREG_FAN_MAX_PWM; i++) {
> +	for (i = 0; i < MLXREG_FAN_MAX_PWM; i++) {
>  		struct mlxreg_fan_pwm *pwm = &fan->pwm[i];
>  
>  		if (!pwm->connected)

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

end of thread, other threads:[~2021-09-24  1:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 17:41 [PATCH hwmon-next 1/1] hwmon: (mlxreg-fan) Fix defect reported by Coverity Scan for linux-next Vadim Pasternak
2021-09-24  1:09 ` 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).