* [PATCH] iio: dac: ltc2664: Fix off by one in ltc2664_channel_config()
@ 2024-08-09 12:28 Dan Carpenter
2024-08-10 10:22 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-08-09 12:28 UTC (permalink / raw)
To: Kim Seer Paller
Cc: Michael Hennerich, Jonathan Cameron, Lars-Peter Clausen,
Conor Dooley, Nuno Sa, linux-iio, linux-kernel, kernel-janitors
This comparison should be >= ARRAY_SIZE() instead of >. The "mspan"
variable is later used as an array index into ltc2664_mspan_lut[] so
this is an off by one bug.
Fixes: 4cc2fc445d2e ("iio: dac: ltc2664: Add driver for LTC2664 and LTC2672")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/iio/dac/ltc2664.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/dac/ltc2664.c b/drivers/iio/dac/ltc2664.c
index 666ecdeb5f96..5be5345ac5c8 100644
--- a/drivers/iio/dac/ltc2664.c
+++ b/drivers/iio/dac/ltc2664.c
@@ -526,7 +526,7 @@ static int ltc2664_channel_config(struct ltc2664_state *st)
return dev_err_probe(dev, -EINVAL,
"adi,manual-span-operation-config not supported\n");
- if (mspan > ARRAY_SIZE(ltc2664_mspan_lut))
+ if (mspan >= ARRAY_SIZE(ltc2664_mspan_lut))
return dev_err_probe(dev, -EINVAL,
"adi,manual-span-operation-config not in range\n");
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: dac: ltc2664: Fix off by one in ltc2664_channel_config()
2024-08-09 12:28 [PATCH] iio: dac: ltc2664: Fix off by one in ltc2664_channel_config() Dan Carpenter
@ 2024-08-10 10:22 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-08-10 10:22 UTC (permalink / raw)
To: Dan Carpenter
Cc: Kim Seer Paller, Michael Hennerich, Lars-Peter Clausen,
Conor Dooley, Nuno Sa, linux-iio, linux-kernel, kernel-janitors
On Fri, 9 Aug 2024 15:28:30 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> This comparison should be >= ARRAY_SIZE() instead of >. The "mspan"
> variable is later used as an array index into ltc2664_mspan_lut[] so
> this is an off by one bug.
>
> Fixes: 4cc2fc445d2e ("iio: dac: ltc2664: Add driver for LTC2664 and LTC2672")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Applied.
Thanks,
> ---
> drivers/iio/dac/ltc2664.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ltc2664.c b/drivers/iio/dac/ltc2664.c
> index 666ecdeb5f96..5be5345ac5c8 100644
> --- a/drivers/iio/dac/ltc2664.c
> +++ b/drivers/iio/dac/ltc2664.c
> @@ -526,7 +526,7 @@ static int ltc2664_channel_config(struct ltc2664_state *st)
> return dev_err_probe(dev, -EINVAL,
> "adi,manual-span-operation-config not supported\n");
>
> - if (mspan > ARRAY_SIZE(ltc2664_mspan_lut))
> + if (mspan >= ARRAY_SIZE(ltc2664_mspan_lut))
> return dev_err_probe(dev, -EINVAL,
> "adi,manual-span-operation-config not in range\n");
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-10 10:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09 12:28 [PATCH] iio: dac: ltc2664: Fix off by one in ltc2664_channel_config() Dan Carpenter
2024-08-10 10:22 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox