From c87de56bfb3c107a2a65e92b81846cc68a32356e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 12 Dec 2011 09:33:14 +0100 Subject: [PATCH] --- yaml --- r: 281356 b: refs/heads/master c: 8fe64955e47277abf4a3ec56383ea9b9487bd029 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/staging/iio/buffer.h | 2 +- trunk/drivers/staging/iio/kfifo_buf.c | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 880d8eedeb1a..75ee5024c891 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 641b4bb5f1c51a68f5aec7d3b47c96b39820b105 +refs/heads/master: 8fe64955e47277abf4a3ec56383ea9b9487bd029 diff --git a/trunk/drivers/staging/iio/buffer.h b/trunk/drivers/staging/iio/buffer.h index c69709925ba2..44593b28b36f 100644 --- a/trunk/drivers/staging/iio/buffer.h +++ b/trunk/drivers/staging/iio/buffer.h @@ -21,7 +21,7 @@ struct iio_buffer; * @mark_in_use: reference counting, typically to prevent module removal * @unmark_in_use: reduce reference count when no longer using buffer * @store_to: actually store stuff to the buffer - * @read_first_n: try to get a specified number of elements (must exist) + * @read_first_n: try to get a specified number of bytes (must exist) * @mark_param_change: notify buffer that some relevant parameter has changed * Often this means the underlying storage may need to * change. diff --git a/trunk/drivers/staging/iio/kfifo_buf.c b/trunk/drivers/staging/iio/kfifo_buf.c index d8867abd0a84..b69cca5e43ca 100644 --- a/trunk/drivers/staging/iio/kfifo_buf.c +++ b/trunk/drivers/staging/iio/kfifo_buf.c @@ -160,7 +160,11 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r, int ret, copied; struct iio_kfifo *kf = iio_to_kfifo(r); - ret = kfifo_to_user(&kf->kf, buf, r->bytes_per_datum*n, &copied); + if (n < r->bytes_per_datum) + return -EINVAL; + + n = rounddown(n, r->bytes_per_datum); + ret = kfifo_to_user(&kf->kf, buf, n, &copied); return copied; }