]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: buffer: Fix wait_queue not being removed
authorNuno Sá <nuno.sa@analog.com>
Mon, 16 Feb 2026 13:24:27 +0000 (13:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Mar 2026 15:15:30 +0000 (16:15 +0100)
commit 064234044056c93a3719d6893e6e5a26a94a61b6 upstream.

In the edge case where the IIO device is unregistered while we're
buffering, we were directly returning an error without removing the wait
queue. Instead, set 'ret' and break out of the loop.

Fixes: 9eeee3b0bf19 ("iio: Add output buffer support")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/industrialio-buffer.c

index c6259213e15035b8126712097923e7fa0a3c3e4e..a09c0d263d7febd9929a6c8862a203d78dfab95c 100644 (file)
@@ -228,8 +228,10 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
        written = 0;
        add_wait_queue(&rb->pollq, &wait);
        do {
-               if (!indio_dev->info)
-                       return -ENODEV;
+               if (!indio_dev->info) {
+                       ret = -ENODEV;
+                       break;
+               }
 
                if (!iio_buffer_space_available(rb)) {
                        if (signal_pending(current)) {