This is a note to let you know that I've just added the patch titled iio: buffer: correctly return bytes written in output buffers to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: iio-buffer-correctly-return-bytes-written-in-output-buffers.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From b5184a26a28fac1d708b0bfeeb958a9260c2924c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= <nuno.sa@xxxxxxxxxx> Date: Thu, 16 Feb 2023 11:14:50 +0100 Subject: iio: buffer: correctly return bytes written in output buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Nuno Sá <nuno.sa@xxxxxxxxxx> commit b5184a26a28fac1d708b0bfeeb958a9260c2924c upstream. 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: 9eeee3b0bf190 ("iio: Add output buffer support") Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx> Reviewed-by: Lars-Peter Clausen <lars@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230216101452.591805-2-nuno.sa@xxxxxxxxxx Cc: <Stable@xxxxxxxxxxxxxxx> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/iio/industrialio-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -220,7 +220,7 @@ static ssize_t iio_buffer_write(struct f } while (ret == 0); remove_wait_queue(&rb->pollq, &wait); - return ret < 0 ? ret : n; + return ret < 0 ? ret : written; } /** Patches currently in stable-queue which might be from nuno.sa@xxxxxxxxxx are queue-6.1/iio-buffer-correctly-return-bytes-written-in-output-buffers.patch queue-6.1/iio-adis16480-select-config_crc32.patch queue-6.1/iio-buffer-make-sure-o_nonblock-is-respected.patch