Commit 4f6ca346 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jonathan Cameron
Browse files

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: 4cc2fc44 ("iio: dac: ltc2664: Add driver for LTC2664 and LTC2672")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/5727ab54-6280-466e-b107-1b6006e5ab29@stanley.mountain


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent b09999ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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");
	}