Re: [PATCH] iio: backend: fix uninitialized data in debugfs
Jonathan Cameron <[email protected]>
| Newsgroups | org.kernel.vger.kernel-janitors,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260526191946.409160c8@jic23-huawei> |
On Mon, 25 May 2026 08:20:31 -0500 Maxwell Doose <[email protected]> wrote: > On Mon, May 25, 2026 at 2:17 AM Dan Carpenter <[email protected]> wrote: > > > > If the *ppos value is non-zero then simple_write_to_buffer() will not > > initialize the start of the buf[] buffer. Non-zero ppos values aren't > > going to work at all. Check for that at the start of the function and > > return -EINVAL. > > > > Commit message is incorrect, it looks like you're returning -ENOSPC here... Tweaked and applied to the fixes-togreg branch of iio.git + marked for stable. thanks, J > > > > > Fixes: cdf01e0809a4 ("iio: backend: add debugFs interface") > > Signed-off-by: Dan Carpenter <[email protected]> > > --- > > drivers/iio/industrialio-backend.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c > > index 138ebebc9c0d..4763e224ebc6 100644 > > --- a/drivers/iio/industrialio-backend.c > > +++ b/drivers/iio/industrialio-backend.c > > @@ -156,7 +156,7 @@ static ssize_t iio_backend_debugfs_write_reg(struct file *file, > > ssize_t rc; > > int ret; > > > > - if (count >= sizeof(buf)) > > + if (*ppos != 0 || count >= sizeof(buf)) > > return -ENOSPC; > > > > See above comment. > > best regards, > max > > > > > > rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf, count); > > -- > > 2.53.0 > > > >