Skip to content

Commit 08ce9b4

Browse files
committed
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>
1 parent c559afb commit 08ce9b4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/iio/kfifo_buf.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
108108
int ret, copied;
109109
struct iio_kfifo *kf = iio_to_kfifo(r);
110110

111-
if (n < r->bytes_per_datum)
111+
if (n < r->bytes_per_datum || r->bytes_per_datum == 0)
112112
return -EINVAL;
113113

114114
ret = kfifo_to_user(&kf->kf, buf, n, &copied);
115+
if (ret < 0)
116+
return ret;
115117

116118
return copied;
117119
}

0 commit comments

Comments
 (0)