From: Dan Carpenter <dan.carpenter@linaro.org>
To: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] iio: light: apds9306: Fix off by one in apds9306_sampling_freq_get()
Date: Thu, 4 Apr 2024 10:31:25 +0300 [thread overview]
Message-ID: <69c5cb83-0209-40ff-a276-a0ae5e81c528@moroto.mountain> (raw)
The > comparison needs to be >= to prevent an out of bounds access.
Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/iio/light/apds9306.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
index 4d8490602cd7..49fa6b7d5170 100644
--- a/drivers/iio/light/apds9306.c
+++ b/drivers/iio/light/apds9306.c
@@ -635,7 +635,7 @@ static int apds9306_sampling_freq_get(struct apds9306_data *data, int *val,
if (ret)
return ret;
- if (repeat_rate_idx > ARRAY_SIZE(apds9306_repeat_rate_freq))
+ if (repeat_rate_idx >= ARRAY_SIZE(apds9306_repeat_rate_freq))
return -EINVAL;
*val = apds9306_repeat_rate_freq[repeat_rate_idx][0];
--
2.43.0
next reply other threads:[~2024-04-04 7:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 7:31 Dan Carpenter [this message]
2024-04-05 7:14 ` [PATCH] iio: light: apds9306: Fix off by one in apds9306_sampling_freq_get() Subhajit Ghosh
2024-04-06 15:42 ` 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=69c5cb83-0209-40ff-a276-a0ae5e81c528@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=subhajit.ghosh@tweaklogic.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).