All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [chrome-os:chromeos-5.4 90/99] kernel/dma/swiotlb.c:665 swiotlb_tbl_map_single() warn: unsigned 'index' is never less than zero.
Date: Thu, 04 Mar 2021 05:47:59 +0800	[thread overview]
Message-ID: <202103040554.dFYoXKpD-lkp@intel.com> (raw)

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

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.4
head:   f48859423bcc5a5dc65f30eb1dd540af19cf5ebe
commit: 7220eb41bd99b5deba749d2f809ae08ca701de03 [90/99] BACKPORT: FROMLIST: swiotlb: Refactor swiotlb_tbl_{map,unmap}_single
config: i386-randconfig-m021-20210303 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

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

smatch warnings:
kernel/dma/swiotlb.c:665 swiotlb_tbl_map_single() warn: unsigned 'index' is never less than zero.

vim +/index +665 kernel/dma/swiotlb.c

   641	
   642	phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
   643					   dma_addr_t tbl_dma_addr,
   644					   phys_addr_t orig_addr,
   645					   size_t mapping_size,
   646					   size_t alloc_size,
   647					   enum dma_data_direction dir,
   648					   unsigned long attrs)
   649	{
   650		struct swiotlb *swiotlb = get_swiotlb(hwdev);
   651		phys_addr_t tlb_addr;
   652		unsigned int nslots, index;
   653		int i;
   654	
   655		if (mem_encrypt_active())
   656			pr_warn_once("Memory encryption is active and system is using DMA bounce buffers\n");
   657	
   658		if (mapping_size > alloc_size) {
   659			dev_warn_once(hwdev, "Invalid sizes (mapping: %zd bytes, alloc: %zd bytes)",
   660				      mapping_size, alloc_size);
   661			return (phys_addr_t)DMA_MAPPING_ERROR;
   662		}
   663	
   664		index = swiotlb_tbl_find_free_region(hwdev, tbl_dma_addr, alloc_size, attrs);
 > 665		if (index < 0)
   666			return (phys_addr_t)DMA_MAPPING_ERROR;
   667	
   668		tlb_addr = swiotlb->start + (index << IO_TLB_SHIFT);
   669	
   670		/*
   671		 * Save away the mapping from the original address to the DMA address.
   672		 * This is needed when we sync the memory.  Then we sync the buffer if
   673		 * needed.
   674		 */
   675		nslots = ALIGN(alloc_size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
   676		for (i = 0; i < nslots; i++)
   677			swiotlb->orig_addr[index + i] = orig_addr + (i << IO_TLB_SHIFT);
   678		if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
   679		    (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
   680			swiotlb_bounce(orig_addr, tlb_addr, mapping_size, DMA_TO_DEVICE);
   681	
   682		return tlb_addr;
   683	}
   684	

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

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

                 reply	other threads:[~2021-03-03 21:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202103040554.dFYoXKpD-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.