From: Jonathan Cameron Date: Mon, 27 Aug 2012 17:40:04 +0000 (+0100) Subject: iio:kfifo_buf improve error handling in read_first_n. X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=08ce9b44b53c580987b6a63df4e2206e45e20b92;p=openwrt%2Fstaging%2Fblogic.git 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 Tested-by: Lars-Peter Clausen --- diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c index 8a6d28ce21b2..6ec763f1202a 100644 --- a/drivers/iio/kfifo_buf.c +++ b/drivers/iio/kfifo_buf.c @@ -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; }