Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio: light: apds9306: Fix off by one in apds9306_sampling_freq_get()
Date: Sat, 6 Apr 2024 16:42:35 +0100	[thread overview]
Message-ID: <20240406164235.55193b5f@jic23-huawei> (raw)
In-Reply-To: <7a54d993-8aff-472f-8132-85e0ca79ff13@tweaklogic.com>

On Fri, 5 Apr 2024 17:44:31 +1030
Subhajit Ghosh <subhajit.ghosh@tweaklogic.com> wrote:

> On 4/4/24 18:01, Dan Carpenter wrote:
> > 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;  
> Good find.
> 
> Reviewed-by: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
> 
Applied to the togreg branch of iio.git (where the fixes patch is currently)
and pushed out as testing initially because there is other stuff in there
I want 0-day to checkout before I make a mess of linux-next.

Thanks,

Jonathan

> Regards,
> Subhajit Ghosh
> >   
> >   	*val = apds9306_repeat_rate_freq[repeat_rate_idx][0];  
> 


      reply	other threads:[~2024-04-06 15:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04  7:31 [PATCH] iio: light: apds9306: Fix off by one in apds9306_sampling_freq_get() Dan Carpenter
2024-04-05  7:14 ` Subhajit Ghosh
2024-04-06 15:42   ` Jonathan Cameron [this message]

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=20240406164235.55193b5f@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=dan.carpenter@linaro.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