aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/iio/buffer/kfifo_buf.c
diff options
context:
space:
mode:
authorMartin Kelly <mkelly@xevo.com>2018-03-26 14:27:51 -0700
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-03-30 11:14:32 +0100
commitc043ec1ca5baae63726aae32abbe003192bc6eec (patch)
tree51574cd7d82dec8175c75f9f4498fd38fa8bb68d /drivers/iio/buffer/kfifo_buf.c
parentiio: adc: stm32-dfsdm: fix sample rate for div2 spi clock (diff)
downloadwireguard-linux-c043ec1ca5baae63726aae32abbe003192bc6eec.tar.xz
wireguard-linux-c043ec1ca5baae63726aae32abbe003192bc6eec.zip
iio:buffer: make length types match kfifo types
Currently, we use int for buffer length and bytes_per_datum. However, kfifo uses unsigned int for length and size_t for element size. We need to make sure these matches or we will have bugs related to overflow (in the range between INT_MAX and UINT_MAX for length, for example). In addition, set_bytes_per_datum uses size_t while bytes_per_datum is an int, which would cause bugs for large values of bytes_per_datum. Change buffer length to use unsigned int and bytes_per_datum to use size_t. Signed-off-by: Martin Kelly <mkelly@xevo.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/buffer/kfifo_buf.c')
-rw-r--r--drivers/iio/buffer/kfifo_buf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
index 047fe757ab97..ac622edf2486 100644
--- a/drivers/iio/buffer/kfifo_buf.c
+++ b/drivers/iio/buffer/kfifo_buf.c
@@ -22,7 +22,7 @@ struct iio_kfifo {
#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, buffer)
static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
- int bytes_per_datum, int length)
+ size_t bytes_per_datum, unsigned int length)
{
if ((length == 0) || (bytes_per_datum == 0))
return -EINVAL;
@@ -67,7 +67,7 @@ static int iio_set_bytes_per_datum_kfifo(struct iio_buffer *r, size_t bpd)
return 0;
}
-static int iio_set_length_kfifo(struct iio_buffer *r, int length)
+static int iio_set_length_kfifo(struct iio_buffer *r, unsigned int length)
{
/* Avoid an invalid state */
if (length < 2)