All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [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)'
Date: Thu, 18 Feb 2021 00:20:33 +0800	[thread overview]
Message-ID: <202102180028.0AN3Cfyt-lkp@intel.com> (raw)

[-- 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 --]

             reply	other threads:[~2021-02-17 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 16:20 kernel test robot [this message]
2021-02-19  7:32 ` [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)' Ardelean, Alexandru
2021-02-19  7:32 ` Ardelean, Alexandru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202102180028.0AN3Cfyt-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.