Skip to content

Commit c28835b

Browse files
error27gregkh
authored andcommitted
iio: backend: fix uninitialized data in debugfs
commit a6e8b14 upstream. 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 -ENOSPC. Fixes: cdf01e0 ("iio: backend: add debugFs interface") Signed-off-by: Dan Carpenter <error27@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0f30e68 commit c28835b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/industrialio-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static ssize_t iio_backend_debugfs_write_reg(struct file *file,
155155
ssize_t rc;
156156
int ret;
157157

158-
if (count >= sizeof(buf))
158+
if (*ppos != 0 || count >= sizeof(buf))
159159
return -ENOSPC;
160160

161161
rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf, count);

0 commit comments

Comments
 (0)