From: Dan Carpenter Date: Fri, 9 Aug 2024 12:28:30 +0000 (+0300) Subject: iio: dac: ltc2664: Fix off by one in ltc2664_channel_config() X-Git-Tag: v6.12-rc1~39^2~37^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f6ca3464d987054f5e75f097a97dcbb86a87569;p=thirdparty%2Fkernel%2Flinux.git iio: dac: ltc2664: Fix off by one in ltc2664_channel_config() 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 Link: https://patch.msgid.link/5727ab54-6280-466e-b107-1b6006e5ab29@stanley.mountain Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/dac/ltc2664.c b/drivers/iio/dac/ltc2664.c index 666ecdeb5f961..5be5345ac5c85 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"); }