From: Guenter Roeck <linux@roeck-us.net>
To: Colin King <colin.king@canonical.com>
Cc: Jean Delvare <jdelvare@suse.com>,
Vadim Pasternak <vadimp@nvidia.com>,
linux-hwmon@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] hwmon: (mlxreg-fan): Fix out of bounds read on array fan->pwm
Date: Thu, 23 Sep 2021 18:06:04 -0700 [thread overview]
Message-ID: <20210924010604.GA3029410@roeck-us.net> (raw)
In-Reply-To: <20210920180921.16246-1-colin.king@canonical.com>
On Mon, Sep 20, 2021 at 07:09:21PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Array fan->pwm[] is MLXREG_FAN_MAX_PWM elements in size, however the
> for-loop has a off-by-one error causing index i to be out of range
> causing an out of bounds read on the array. Fix this by replacing
> the <= operator with < in the for-loop.
>
> Addresses-Coverity: ("Out-of-bounds read")
> Fixes: 35edbaab3bbf ("hwmon: (mlxreg-fan) Extend driver to support multiply cooling devices")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied.
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)
prev parent reply other threads:[~2021-09-24 1:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 18:09 [PATCH][next] hwmon: (mlxreg-fan): Fix out of bounds read on array fan->pwm Colin King
2021-09-24 1:06 ` Guenter Roeck [this message]
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=20210924010604.GA3029410@roeck-us.net \
--to=linux@roeck-us.net \
--cc=colin.king@canonical.com \
--cc=jdelvare@suse.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vadimp@nvidia.com \
/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