diff mbox series

[2/2] iio: buffer-dma: fix type of 'i' in iio_dma_buffer_alloc_blocks()

Message ID 20210219085826.46622-3-alexandru.ardelean@analog.com (mailing list archive)
State New, archived
Headers show
Series iio: core,buffer-dma: 2 fixes for the recent IIO buffer series | expand

Commit Message

Alexandru Ardelean Feb. 19, 2021, 8:58 a.m. UTC
When unwinding the cleanup of the blocks, the type of 'i' is important to
be signed, so that the 'i >= 0' condition doesn't underflow and infinitely
loop (or just cause an access violation).

Fixes: ab925b044cfb ("iio: buffer-dma: Add mmap support")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/buffer/industrialio-buffer-dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c
index d04479194cb4..83074d060535 100644
--- a/drivers/iio/buffer/industrialio-buffer-dma.c
+++ b/drivers/iio/buffer/industrialio-buffer-dma.c
@@ -707,8 +707,7 @@  int iio_dma_buffer_alloc_blocks(struct iio_buffer *buffer,
 	struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer);
 	struct iio_dma_buffer_block **blocks;
 	unsigned int num_blocks;
-	unsigned int i;
-	int ret = 0;
+	int i, ret = 0;
 
 	mutex_lock(&queue->lock);