Skip to contentSkip to conversation

drivers/md/dm-pcache/cache_dev.c:52:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false

PATCH kernel test robot 1 participant 1 message Aug 15, 2025

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   1357b2649c026b51353c84ddd32bc963e8999603
commit: 6fb8fbbaf147fe4153177320ee354c457605800a [2532/2770] dm-pcache: add persistent cache target in device-mapper
config: loongarch-allyesconfig (https://download.01.org/0day-ci/archive/20250815/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250815/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/md/dm-pcache/cache_dev.c:52:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
      52 |         if (!*vaddr)
         |             ^~~~~~~
   drivers/md/dm-pcache/cache_dev.c:56:9: note: uninitialized use occurs here
      56 |         return ret;
         |                ^~~
   drivers/md/dm-pcache/cache_dev.c:52:2: note: remove the 'if' if its condition is always true
      52 |         if (!*vaddr)
         |         ^~~~~~~~~~~~
      53 |                 ret = -ENOMEM;
   drivers/md/dm-pcache/cache_dev.c:24:9: note: initialize the variable 'ret' to silence this warning
      24 |         int ret;
         |                ^
         |                 = 0

1 warning generated.

vim +52 drivers/md/dm-pcache/cache_dev.c

    18	
    19	static int build_vmap(struct dax_device *dax_dev, long total_pages, void **vaddr)
    20	{
    21		struct page **pages;
    22		long i = 0, chunk;
    23		unsigned long pfn;
    24		int ret;
    25	
    26		pages = vmalloc_array(total_pages, sizeof(struct page *));
    27		if (!pages)
    28			return -ENOMEM;
    29	
    30		do {
    31			chunk = dax_direct_access(dax_dev, i, total_pages - i,
    32						  DAX_ACCESS, NULL, &pfn);
    33			if (chunk <= 0) {
    34				ret = chunk ? chunk : -EINVAL;
    35				goto out_free;
    36			}
    37	
    38			if (!pfn_valid(pfn)) {
    39				ret = -EOPNOTSUPP;
    40				goto out_free;
    41			}
    42	
    43			while (chunk-- && i < total_pages) {
    44				pages[i++] = pfn_to_page(pfn);
    45				pfn++;
    46				if (!(i & 15))
    47					cond_resched();
    48			}
    49		} while (i < total_pages);
    50	
    51		*vaddr = vmap(pages, total_pages, VM_MAP, PAGE_KERNEL);
  > 52		if (!*vaddr)
    53			ret = -ENOMEM;
    54	out_free:
    55		vfree(pages);
    56		return ret;
    57	}
    58	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki