Skip to content

Commit e166a8c

Browse files
error27gregkh
authored andcommitted
iio: core: fix uninitialized data in debugfs
commit ab92ed2 upstream. If *ppos is non-zero then simple_write_to_buffer() will not initialize the start of buf[]. Non zero values for *ppos aren't going to work anyway. Test for them at the start of the function and return -EINVAL. Fixes: 6d5dd48 ("iio: core: make use of simple_write_to_buffer()") Signed-off-by: Dan Carpenter <error27@gmail.com> Reviewed-by: Maxwell Doose <m32285159@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 b947bde commit e166a8c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/industrialio-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static ssize_t iio_debugfs_write_reg(struct file *file,
418418
char buf[80];
419419
int ret;
420420

421-
if (count >= sizeof(buf))
421+
if (*ppos != 0 || count >= sizeof(buf))
422422
return -EINVAL;
423423

424424
ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, userbuf,

0 commit comments

Comments
 (0)