Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [leon-rdma:dmabuf-vfio 38/42] arch/sparc/kernel/iommu.c:275:6: warning: variable 'iommu' is used uninitialized whenever 'if' condition is true
@ 2025-09-16 20:40 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-09-16 20:40 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git dmabuf-vfio
head:   887b59804850b679831fda6eba707cc1b1b077e0
commit: ea58d5c1de6355a98e58cad814b5f77271e9032e [38/42] sparc64: Use physical address DMA mapping
config: sparc64-randconfig-002-20250916 (https://download.01.org/0day-ci/archive/20250917/202509170425.PYGuKwZR-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 65ad21d730d25789454d18e811f8ff5db79cb5d4)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250917/202509170425.PYGuKwZR-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509170425.PYGuKwZR-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/sparc/kernel/iommu.c:275:6: warning: variable 'iommu' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     275 |         if (attrs & DMA_ATTR_MMIO)
         |             ^~~~~~~~~~~~~~~~~~~~~
   arch/sparc/kernel/iommu.c:315:17: note: uninitialized use occurs here
     315 |         iommu_free_ctx(iommu, ctx);
         |                        ^~~~~
   arch/sparc/kernel/iommu.c:275:2: note: remove the 'if' if its condition is always false
     275 |         if (attrs & DMA_ATTR_MMIO)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
     276 |                 goto bad;
         |                 ~~~~~~~~
   arch/sparc/kernel/iommu.c:267:21: note: initialize the variable 'iommu' to silence this warning
     267 |         struct iommu *iommu;
         |                            ^
         |                             = NULL
>> arch/sparc/kernel/iommu.c:275:6: warning: variable 'ctx' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     275 |         if (attrs & DMA_ATTR_MMIO)
         |             ^~~~~~~~~~~~~~~~~~~~~
   arch/sparc/kernel/iommu.c:315:24: note: uninitialized use occurs here
     315 |         iommu_free_ctx(iommu, ctx);
         |                               ^~~
   arch/sparc/kernel/iommu.c:275:2: note: remove the 'if' if its condition is always false
     275 |         if (attrs & DMA_ATTR_MMIO)
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
     276 |                 goto bad;
         |                 ~~~~~~~~
   arch/sparc/kernel/iommu.c:271:34: note: initialize the variable 'ctx' to silence this warning
     271 |         unsigned long i, base_paddr, ctx;
         |                                         ^
         |                                          = 0
   2 warnings generated.


vim +275 arch/sparc/kernel/iommu.c

   262	
   263	static dma_addr_t dma_4u_map_phys(struct device *dev, phys_addr_t phys,
   264					  size_t sz, enum dma_data_direction direction,
   265					  unsigned long attrs)
   266	{
   267		struct iommu *iommu;
   268		struct strbuf *strbuf;
   269		iopte_t *base;
   270		unsigned long flags, npages, oaddr;
   271		unsigned long i, base_paddr, ctx;
   272		u32 bus_addr, ret;
   273		unsigned long iopte_protection;
   274	
 > 275		if (attrs & DMA_ATTR_MMIO)
   276			goto bad;
   277	
   278		iommu = dev->archdata.iommu;
   279		strbuf = dev->archdata.stc;
   280	
   281		if (unlikely(direction == DMA_NONE))
   282			goto bad_no_ctx;
   283	
   284		oaddr = (unsigned long)(phys_to_virt(phys));
   285		npages = IO_PAGE_ALIGN(oaddr + sz) - (oaddr & IO_PAGE_MASK);
   286		npages >>= IO_PAGE_SHIFT;
   287	
   288		base = alloc_npages(dev, iommu, npages);
   289		spin_lock_irqsave(&iommu->lock, flags);
   290		ctx = 0;
   291		if (iommu->iommu_ctxflush)
   292			ctx = iommu_alloc_ctx(iommu);
   293		spin_unlock_irqrestore(&iommu->lock, flags);
   294	
   295		if (unlikely(!base))
   296			goto bad;
   297	
   298		bus_addr = (iommu->tbl.table_map_base +
   299			    ((base - iommu->page_table) << IO_PAGE_SHIFT));
   300		ret = bus_addr | (oaddr & ~IO_PAGE_MASK);
   301		base_paddr = __pa(oaddr & IO_PAGE_MASK);
   302		if (strbuf->strbuf_enabled)
   303			iopte_protection = IOPTE_STREAMING(ctx);
   304		else
   305			iopte_protection = IOPTE_CONSISTENT(ctx);
   306		if (direction != DMA_TO_DEVICE)
   307			iopte_protection |= IOPTE_WRITE;
   308	
   309		for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE)
   310			iopte_val(*base) = iopte_protection | base_paddr;
   311	
   312		return ret;
   313	
   314	bad:
   315		iommu_free_ctx(iommu, ctx);
   316	bad_no_ctx:
   317		if (printk_ratelimit())
   318			WARN_ON(1);
   319		return DMA_MAPPING_ERROR;
   320	}
   321	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-16 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-16 20:40 [leon-rdma:dmabuf-vfio 38/42] arch/sparc/kernel/iommu.c:275:6: warning: variable 'iommu' is used uninitialized whenever 'if' condition is true kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox