All of lore.kernel.org
 help / color / mirror / Atom feed
* [iio:testing 47/53] drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blocks() warn: always true condition '(i >= 0) => (0-u32max >= 0)'
@ 2021-02-17 16:20 kernel test robot
  2021-02-19  7:32 ` Ardelean, Alexandru
  2021-02-19  7:32 ` Ardelean, Alexandru
  0 siblings, 2 replies; 3+ messages in thread
From: kernel test robot @ 2021-02-17 16:20 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3213 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git testing
head:   0fd146b288591a8139220fec417dfc5652820480
commit: b9ad66ba4db6f349aa795ed59c3e42d4208844fa [47/53] iio: buffer-dma: Add mmap support
config: x86_64-randconfig-m001-20210215 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

smatch warnings:
drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blocks() warn: always true condition '(i >= 0) => (0-u32max >= 0)'
drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blocks() warn: always true condition '(i >= 0) => (0-u32max >= 0)'

vim +669 drivers/iio/buffer/industrialio-buffer-dma.c

   603	
   604	int iio_dma_buffer_alloc_blocks(struct iio_buffer *buffer,
   605					struct iio_buffer_block_alloc_req *req)
   606	{
   607		struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer);
   608		struct iio_dma_buffer_block **blocks;
   609		unsigned int num_blocks;
   610		unsigned int i;
   611		int ret = 0;
   612	
   613		mutex_lock(&queue->lock);
   614	
   615		/*
   616		 * If the buffer is enabled and in fileio mode new blocks can't be
   617		 * allocated.
   618		 */
   619		if (queue->fileio.enabled) {
   620			ret = -EBUSY;
   621			goto err_unlock;
   622		}
   623	
   624		/* Free memory that might be in use for fileio mode */
   625		iio_dma_buffer_fileio_free(queue);
   626	
   627		/* 64 blocks ought to be enough for anybody ;) */
   628		if (req->count > 64 - queue->num_blocks)
   629			req->count = 64 - queue->num_blocks;
   630		if (req->size > iio_dma_buffer_max_block_size)
   631			req->size = iio_dma_buffer_max_block_size;
   632	
   633		req->id = queue->num_blocks;
   634	
   635		if (req->count == 0 || req->size == 0) {
   636			ret = 0;
   637			goto err_unlock;
   638		}
   639	
   640		num_blocks = req->count + queue->num_blocks;
   641	
   642		blocks = krealloc(queue->blocks, sizeof(*blocks) * num_blocks,
   643				  GFP_KERNEL);
   644		if (!blocks) {
   645			ret = -ENOMEM;
   646			goto err_unlock;
   647		}
   648	
   649		for (i = queue->num_blocks; i < num_blocks; i++) {
   650			blocks[i] = iio_dma_buffer_alloc_block(queue, req->size);
   651			if (!blocks[i]) {
   652				ret = -ENOMEM;
   653				goto err_unwind;
   654			}
   655			blocks[i]->block.id = i;
   656			blocks[i]->block.data.offset = queue->max_offset;
   657			queue->max_offset += PAGE_ALIGN(req->size);
   658		}
   659	
   660		req->count = i - queue->num_blocks;
   661		queue->num_blocks = i;
   662		queue->blocks = blocks;
   663	
   664		mutex_unlock(&queue->lock);
   665	
   666		return 0;
   667	
   668	err_unwind:
 > 669		for (; i >= 0; i--)
   670			iio_buffer_block_put(blocks[i]);
   671		kfree(blocks);
   672	err_unlock:
   673		mutex_unlock(&queue->lock);
   674	
   675		return ret;
   676	}
   677	EXPORT_SYMBOL_GPL(iio_dma_buffer_alloc_blocks);
   678	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31029 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-19  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 16:20 [iio:testing 47/53] drivers/iio/buffer/industrialio-buffer-dma.c:669 iio_dma_buffer_alloc_blocks() warn: always true condition '(i >= 0) => (0-u32max >= 0)' kernel test robot
2021-02-19  7:32 ` Ardelean, Alexandru
2021-02-19  7:32 ` Ardelean, Alexandru

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.