summaryrefslogtreecommitdiffstats
path: root/include/linux/iio
diff options
context:
space:
mode:
authorMartin Kelly <mkelly@xevo.com>2018-03-26 14:27:51 -0700
committerBen Hutchings <ben@decadent.org.uk>2018-10-21 08:45:05 +0100
commit9e70dd43a078e3cebcc1a044950d93cd8621b7e2 (patch)
tree35fb1d502bfda01788998d710af369e9f35fd00d /include/linux/iio
parentc06c9284eb36773e8c9e992ac8a4da580906a65f (diff)
downloadlinux-stable-9e70dd43a078e3cebcc1a044950d93cd8621b7e2.tar.gz
linux-stable-9e70dd43a078e3cebcc1a044950d93cd8621b7e2.tar.bz2
linux-stable-9e70dd43a078e3cebcc1a044950d93cd8621b7e2.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> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> [bwh: Backported to 3.16: - Drop change in iio_dma_buffer_set_length() - Adjust filenames, context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include/linux/iio')
-rw-r--r--include/linux/iio/buffer.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 519392763393..04e9bb96a5d5 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -52,7 +52,7 @@ struct iio_buffer_access_funcs {
int (*get_bytes_per_datum)(struct iio_buffer *buffer);
int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
int (*get_length)(struct iio_buffer *buffer);
- int (*set_length)(struct iio_buffer *buffer, int length);
+ int (*set_length)(struct iio_buffer *buffer, unsigned int length);
void (*release)(struct iio_buffer *buffer);
};
@@ -78,8 +78,8 @@ struct iio_buffer_access_funcs {
* @ref: [INTERN] reference count of the buffer.
*/
struct iio_buffer {
- int length;
- int bytes_per_datum;
+ unsigned int length;
+ size_t bytes_per_datum;
struct attribute_group *scan_el_attrs;
long *scan_mask;
bool scan_timestamp;