mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-18 06:50:08 +00:00
iio:kfifo_buf improve error handling in read_first_n.
These two elements were originally in the patch iio:kfifo_buf Take advantage of the fixed record size used in IIO but Lars-Peter Clausen pointed out they should not have been so here they are. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Tested-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
c559afbfb0
commit
08ce9b44b5
@ -108,10 +108,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
|
||||
int ret, copied;
|
||||
struct iio_kfifo *kf = iio_to_kfifo(r);
|
||||
|
||||
if (n < r->bytes_per_datum)
|
||||
if (n < r->bytes_per_datum || r->bytes_per_datum == 0)
|
||||
return -EINVAL;
|
||||
|
||||
ret = kfifo_to_user(&kf->kf, buf, n, &copied);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return copied;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user