Skip to content

Commit b5184a2

Browse files
nunojsajic23
authored andcommitted
iio: buffer: correctly return bytes written in output buffers
If for some reason 'rb->access->write()' does not write the full requested data and the O_NONBLOCK is set, we would return 'n' to userspace which is not really truth. Hence, let's return the number of bytes we effectively wrote. Fixes: 9eeee3b ("iio: Add output buffer support") Signed-off-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20230216101452.591805-2-nuno.sa@analog.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 42ec40b commit b5184a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/industrialio-buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
220220
} while (ret == 0);
221221
remove_wait_queue(&rb->pollq, &wait);
222222

223-
return ret < 0 ? ret : n;
223+
return ret < 0 ? ret : written;
224224
}
225225

226226
/**

0 commit comments

Comments
 (0)