提交 08ce9b44 编写于 作者: J Jonathan Cameron

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: NJonathan Cameron <jic23@kernel.org>
Tested-by: NLars-Peter Clausen <lars@metafoo.de>
上级 c559afbf
...@@ -108,10 +108,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r, ...@@ -108,10 +108,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
int ret, copied; int ret, copied;
struct iio_kfifo *kf = iio_to_kfifo(r); 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; return -EINVAL;
ret = kfifo_to_user(&kf->kf, buf, n, &copied); ret = kfifo_to_user(&kf->kf, buf, n, &copied);
if (ret < 0)
return ret;
return copied; return copied;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册