From: Dan Carpenter <dan.carpenter@linaro.org>
To: Kim Seer Paller <kimseer.paller@analog.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Conor Dooley <conor.dooley@microchip.com>,
Nuno Sa <nuno.sa@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] iio: dac: ltc2664: Fix off by one in ltc2664_channel_config()
Date: Fri, 9 Aug 2024 15:28:30 +0300 [thread overview]
Message-ID: <5727ab54-6280-466e-b107-1b6006e5ab29@stanley.mountain> (raw)
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
next reply other threads:[~2024-08-09 12:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 12:28 Dan Carpenter [this message]
2024-08-10 10:22 ` Jonathan Cameron
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=5727ab54-6280-466e-b107-1b6006e5ab29@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=conor.dooley@microchip.com \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kimseer.paller@analog.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=nuno.sa@analog.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
all inboxes | Powered by JetHome®