Re: [PATCH] iio: dac: ad3552r-hs: fix uninitialized data ni ad3552r_hs_write_data_source()

Jonathan Cameron <[email protected]>
Newsgroups org.kernel.vger.kernel-janitors,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <20260526191831.3bf33c0e@jic23-huawei>
On Mon, 25 May 2026 08:21:51 -0500
Maxwell Doose <[email protected]> wrote:

> Hi Dan,
> 
> On Mon, May 25, 2026 at 2:16 AM Dan Carpenter <[email protected]> wrote:
> >
> > If the *ppos value is non-zero then the simple_write_to_buffer() function
> > won't initialized the start of the buf[] buffer.  Non-zero values for
> > *ppos won't work here generally, so just test for them and return -EINVAL
> > at the start of the function.
> >  
> 
> Please see my other email, you're also returning -ENOSPC instead of
> -EINVAL here...
> 
Good spot. Tweaked whilst applying.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks

Jonathan
> >
> > Fixes: b1c5d68ea66e ("iio: dac: ad3552r-hs: add support for internal ramp")
> > Signed-off-by: Dan Carpenter <[email protected]>
> > ---
> >  drivers/iio/dac/ad3552r-hs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c
> > index a9578afa7015..6bc64f53bce9 100644
> > --- a/drivers/iio/dac/ad3552r-hs.c
> > +++ b/drivers/iio/dac/ad3552r-hs.c
> > @@ -549,7 +549,7 @@ static ssize_t ad3552r_hs_write_data_source(struct file *f,
> >
> >         guard(mutex)(&st->lock);
> >
> > -       if (count >= sizeof(buf))
> > +       if (*ppos != 0 || count >= sizeof(buf))
> >                 return -ENOSPC;
> >  
> 
> See above comment.
> 
> best regards,
> max
> 
> 
> 
> >         ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf,
> > --
> > 2.53.0
> >
> >
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.