Skip to content

Commit

Permalink
iio: buffer: correctly return bytes written in output buffers
Browse files Browse the repository at this point in the history
commit b5184a2 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: 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
nunojsa authored and gregkh committed Apr 13, 2023
1 parent 9b180ed commit efdad2f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/industrialio-buffer.c
Expand Up @@ -220,7 +220,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf,
} while (ret == 0);
remove_wait_queue(&rb->pollq, &wait);

return ret < 0 ? ret : n;
return ret < 0 ? ret : written;
}

/**
Expand Down

0 comments on commit efdad2f

Please sign in to comment.