Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [rppt:kho/vmalloc/v4 3/4] kernel/kexec_handover.c:849:15: warning: variable 'num_elms' is uninitialized when used here
@ 2025-09-15 12:52 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-09-15 12:52 UTC (permalink / raw)
  To: Mike Rapoport (Microsoft); +Cc: llvm, oe-kbuild-all, Mike Rapoport

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git kho/vmalloc/v4
head:   4198c802be71f6b2ce7716a8f89fb779b09575a2
commit: 01ea1bd238b11a157114d172bc88608ed08c3b17 [3/4] kho: add support for preserving vmalloc allocations
config: arm64-randconfig-001-20250915 (https://download.01.org/0day-ci/archive/20250915/202509152038.NqSCwQU9-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/20250915/202509152038.NqSCwQU9-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/202509152038.NqSCwQU9-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/kexec_handover.c:849:15: warning: variable 'num_elms' is uninitialized when used here [-Wuninitialized]
     849 |                 chunk->phys[num_elms++] = phys;
         |                             ^~~~~~~~
   kernel/kexec_handover.c:824:37: note: initialize the variable 'num_elms' to silence this warning
     824 |         unsigned int order, flags, num_elms, nr_contig_pages;
         |                                            ^
         |                                             = 0
   1 warning generated.


vim +/num_elms +849 kernel/kexec_handover.c

   804	
   805	/**
   806	 * kho_preserve_vmalloc - preserve memory allocated with vmalloc() across kexec
   807	 * @ptr: pointer to the area in vmalloc address space
   808	 * @preservation: placeholder for preservation metadata
   809	 *
   810	 * Instructs KHO to preserve the area in vmalloc address space at @ptr. The
   811	 * physical pages mapped at @ptr will be preserved and on successful return
   812	 * @preservation will hold the physical address of a structure that describes
   813	 * the preservation.
   814	 *
   815	 * NOTE: The memory allocated with vmalloc_node() variants cannot be reliably
   816	 * restored on the same node
   817	 *
   818	 * Return: 0 on success, error code on failure
   819	 */
   820	int kho_preserve_vmalloc(void *ptr, struct kho_vmalloc *preservation)
   821	{
   822		struct kho_vmalloc_chunk *chunk;
   823		struct vm_struct *vm = find_vm_area(ptr);
   824		unsigned int order, flags, num_elms, nr_contig_pages;
   825		int err;
   826	
   827		if (!vm)
   828			return -EINVAL;
   829	
   830		if (vm->flags & ~KHO_VMALLOC_FLAGS_MASK)
   831			return -EOPNOTSUPP;
   832	
   833		flags = vm->flags & KHO_VMALLOC_FLAGS_MASK;
   834		order = get_vm_area_page_order(vm);
   835	
   836		chunk = new_vmalloc_chunk(NULL);
   837		if (!chunk)
   838			return -ENOMEM;
   839		KHOSER_STORE_PTR(preservation->first, chunk);
   840	
   841		nr_contig_pages = (1 << order);
   842		for (int i = 0; i < vm->nr_pages; i += nr_contig_pages) {
   843			phys_addr_t phys = page_to_phys(vm->pages[i]);
   844	
   845			err = kho_preserve_pages(vm->pages[i], nr_contig_pages);
   846			if (err)
   847				goto err_free;
   848	
 > 849			chunk->phys[num_elms++] = phys;
   850			if (num_elms == ARRAY_SIZE(chunk->phys)) {
   851				chunk = new_vmalloc_chunk(chunk);
   852				if (!chunk)
   853					goto err_free;
   854			}
   855		}
   856	
   857		preservation->total_pages = vm->nr_pages;
   858		preservation->flags = flags;
   859		preservation->order = order;
   860	
   861		return 0;
   862	
   863	err_free:
   864		kho_vmalloc_free_chunks(preservation);
   865		return err;
   866	}
   867	EXPORT_SYMBOL_GPL(kho_preserve_vmalloc);
   868	

-- 
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-15 12:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 12:52 [rppt:kho/vmalloc/v4 3/4] kernel/kexec_handover.c:849:15: warning: variable 'num_elms' is uninitialized when used here 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