drivers/acpi/riscv/irq.c:161:24-28: ERROR: invalid reference to the index variable of the iterator on line 155

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Sunil V L <[email protected]>
CC: Paul Walmsley <[email protected]>
CC: Anup Patel <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bcc44b6785f216eb939226ade6e3910baa30516b
commit: 4d185fdeef67d0c2c5d4a142392cf1ade3786dd2 ACPI: RISC-V: Add support to update gsi range
date:   11 months ago
:::::: branch date: 2 hours ago
:::::: commit date: 11 months ago
config: riscv-randconfig-r063-20260807 (https://download.01.org/0day-ci/archive/20260808/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)

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
| Fixes: 4d185fdeef67 ("ACPI: RISC-V: Add support to update gsi range")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)
>> drivers/acpi/riscv/irq.c:161:24-28: ERROR: invalid reference to the index variable of the iterator on line 155

vim +161 drivers/acpi/riscv/irq.c

e77b8dc02a1ca22 Sunil V L 2024-08-12  133  
e77b8dc02a1ca22 Sunil V L 2024-08-12  134  static int __init riscv_acpi_register_ext_intc(u32 gsi_base, u32 nr_irqs, u32 nr_idcs,
e77b8dc02a1ca22 Sunil V L 2024-08-12  135  					       u32 id, u32 type)
e77b8dc02a1ca22 Sunil V L 2024-08-12  136  {
4d185fdeef67d0c Sunil V L 2025-08-18  137  	struct riscv_ext_intc_list *ext_intc_element, *node, *prev;
e77b8dc02a1ca22 Sunil V L 2024-08-12  138  
e77b8dc02a1ca22 Sunil V L 2024-08-12  139  	ext_intc_element = kzalloc(sizeof(*ext_intc_element), GFP_KERNEL);
e77b8dc02a1ca22 Sunil V L 2024-08-12  140  	if (!ext_intc_element)
e77b8dc02a1ca22 Sunil V L 2024-08-12  141  		return -ENOMEM;
e77b8dc02a1ca22 Sunil V L 2024-08-12  142  
e77b8dc02a1ca22 Sunil V L 2024-08-12  143  	ext_intc_element->gsi_base = gsi_base;
4d185fdeef67d0c Sunil V L 2025-08-18  144  
4d185fdeef67d0c Sunil V L 2025-08-18  145  	/* If nr_irqs is zero, indicate it in flag and set to max range possible */
4d185fdeef67d0c Sunil V L 2025-08-18  146  	if (nr_irqs) {
e77b8dc02a1ca22 Sunil V L 2024-08-12  147  		ext_intc_element->nr_irqs = nr_irqs;
4d185fdeef67d0c Sunil V L 2025-08-18  148  	} else {
4d185fdeef67d0c Sunil V L 2025-08-18  149  		ext_intc_element->flag |= RISCV_ACPI_INTC_FLAG_PENDING;
4d185fdeef67d0c Sunil V L 2025-08-18  150  		ext_intc_element->nr_irqs = U32_MAX - ext_intc_element->gsi_base;
4d185fdeef67d0c Sunil V L 2025-08-18  151  	}
4d185fdeef67d0c Sunil V L 2025-08-18  152  
e77b8dc02a1ca22 Sunil V L 2024-08-12  153  	ext_intc_element->nr_idcs = nr_idcs;
e77b8dc02a1ca22 Sunil V L 2024-08-12  154  	ext_intc_element->id = id;
694b2ef1e73c5ee Sunil V L 2025-08-18 @155  	list_for_each_entry(node, &ext_intc_list, list) {
694b2ef1e73c5ee Sunil V L 2025-08-18  156  		if (node->gsi_base < ext_intc_element->gsi_base)
694b2ef1e73c5ee Sunil V L 2025-08-18  157  			break;
694b2ef1e73c5ee Sunil V L 2025-08-18  158  	}
694b2ef1e73c5ee Sunil V L 2025-08-18  159  
4d185fdeef67d0c Sunil V L 2025-08-18  160  	/* Adjust the previous node's GSI range if that has pending registration */
4d185fdeef67d0c Sunil V L 2025-08-18 @161  	prev = list_prev_entry(node, list);
4d185fdeef67d0c Sunil V L 2025-08-18  162  	if (!list_entry_is_head(prev, &ext_intc_list, list)) {
4d185fdeef67d0c Sunil V L 2025-08-18  163  		if (prev->flag & RISCV_ACPI_INTC_FLAG_PENDING)
4d185fdeef67d0c Sunil V L 2025-08-18  164  			prev->nr_irqs = ext_intc_element->gsi_base - prev->gsi_base;
4d185fdeef67d0c Sunil V L 2025-08-18  165  	}
4d185fdeef67d0c Sunil V L 2025-08-18  166  
694b2ef1e73c5ee Sunil V L 2025-08-18  167  	list_add_tail(&ext_intc_element->list, &node->list);
e77b8dc02a1ca22 Sunil V L 2024-08-12  168  	return 0;
e77b8dc02a1ca22 Sunil V L 2024-08-12  169  }
e77b8dc02a1ca22 Sunil V L 2024-08-12  170  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.