public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
From: Vadim Pasternak <vadimp@nvidia.com>
To: <linux@roeck-us.net>
Cc: <linux-hwmon@vger.kernel.org>, Vadim Pasternak <vadimp@nvidia.com>
Subject: [PATCH hwmon-next 1/1] hwmon: (mlxreg-fan) Fix defect reported by Coverity Scan for linux-next
Date: Mon, 20 Sep 2021 20:41:18 +0300	[thread overview]
Message-ID: <20210920174119.1080488-1-vadimp@nvidia.com> (raw)

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


             reply	other threads:[~2021-09-20 17:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 17:41 Vadim Pasternak [this message]
2021-09-24  1:09 ` [PATCH hwmon-next 1/1] hwmon: (mlxreg-fan) Fix defect reported by Coverity Scan for linux-next 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=20210920174119.1080488-1-vadimp@nvidia.com \
    --to=vadimp@nvidia.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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