summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMartin Kelly <mkelly@xevo.com>2018-03-26 14:27:51 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-06-05 11:41:58 +0200
commit30ab9366f763928176793469fb5c3e0ebe89aeb5 (patch)
tree7dfc8f69f3e6ed49356cd09fecadb01803b196ec /include
parentd30819abd1c4768ba976821465c682e66e1605ee (diff)
downloadlinux-stable-30ab9366f763928176793469fb5c3e0ebe89aeb5.tar.gz
linux-stable-30ab9366f763928176793469fb5c3e0ebe89aeb5.tar.bz2
linux-stable-30ab9366f763928176793469fb5c3e0ebe89aeb5.zip
iio:buffer: make length types match kfifo types
commit c043ec1ca5baae63726aae32abbe003192bc6eec upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/iio/buffer_impl.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/iio/buffer_impl.h b/include/linux/iio/buffer_impl.h
index b9e22b7e2f28..d1171db23742 100644
--- a/include/linux/iio/buffer_impl.h
+++ b/include/linux/iio/buffer_impl.h
@@ -53,7 +53,7 @@ struct iio_buffer_access_funcs {
int (*request_update)(struct iio_buffer *buffer);
int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
- int (*set_length)(struct iio_buffer *buffer, int length);
+ int (*set_length)(struct iio_buffer *buffer, unsigned int length);
int (*enable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
int (*disable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
@@ -72,10 +72,10 @@ struct iio_buffer_access_funcs {
*/
struct iio_buffer {
/** @length: Number of datums in buffer. */
- int length;
+ unsigned int length;
/** @bytes_per_datum: Size of individual datum including timestamp. */
- int bytes_per_datum;
+ size_t bytes_per_datum;
/**
* @access: Buffer access functions associated with the