]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
iio: buffer: make sure O_NONBLOCK is respected
authorNuno Sá <nuno.sa@analog.com>
Thu, 16 Feb 2023 10:14:51 +0000 (11:14 +0100)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Wed, 17 May 2023 11:33:58 +0000 (13:33 +0200)
commitc7cf702d398cca783aac0eb0683e46bf12935289
tree9e9284572aea9a22aeb5c0f986b4a0d027502851
parenta2c2ac116c24e130c7bf39f4a89f2300d0959428
iio: buffer: make sure O_NONBLOCK is respected

BugLink: https://bugs.launchpad.net/bugs/2016879
commit 3da1814184582ed0faf039275a3f02e6f69944ee upstream.

For output buffers, there's no guarantee that the buffer won't be full
in the first iteration of the loop in which case we would block
independently of userspace passing O_NONBLOCK or not. Fix it by always
checking the flag before going to sleep.

While at it (and as it's a bit related), refactored the loop so that the
stop condition is 'written != n', i.e, run the loop until all data has
been copied into the IIO buffers. This makes the code a bit simpler.

Fixes: 9eeee3b0bf190 ("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-3-nuno.sa@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/iio/industrialio-buffer.c