Commit 08ce9b44b53c580987b6a63df4e2206e45e20b92
1 parent
c559afbfb0
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
drivers/iio/kfifo_buf.c
... | ... | @@ -108,10 +108,12 @@ |
108 | 108 | int ret, copied; |
109 | 109 | struct iio_kfifo *kf = iio_to_kfifo(r); |
110 | 110 | |
111 | - if (n < r->bytes_per_datum) | |
111 | + if (n < r->bytes_per_datum || r->bytes_per_datum == 0) | |
112 | 112 | return -EINVAL; |
113 | 113 | |
114 | 114 | ret = kfifo_to_user(&kf->kf, buf, n, &copied); |
115 | + if (ret < 0) | |
116 | + return ret; | |
115 | 117 | |
116 | 118 | return copied; |
117 | 119 | } |