]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: dac: ltc2664: Fix off by one in ltc2664_channel_config()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 9 Aug 2024 12:28:30 +0000 (15:28 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 10 Aug 2024 10:22:11 +0000 (11:22 +0100)
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>
Link: https://patch.msgid.link/5727ab54-6280-466e-b107-1b6006e5ab29@stanley.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ltc2664.c

index 666ecdeb5f961875a09bbe7c9765c408642e2425..5be5345ac5c85448050ba219c13c3b258eb03b77 100644 (file)
@@ -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");
        }