Skip to contentSkip to conversation

drivers/irqchip/irq-riscv-imsic-platform.c:317 imsic_irqdomain_init() warn: variable dereferenced before check 'imsic' (see line 311)

DISCUSSION kernel test robot 1 participant 1 message Jul 31, 2025

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Marc Zyngier <[email protected]>
CC: Thomas Gleixner <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   260f6f4fda93c8485c8037865c941b42b9cba5d2
commit: 59422904dd9855f94d00dc66598bef1bd2663894 irqchip/riscv-imsic: Convert to msi_create_parent_irq_domain() helper
date:   4 weeks ago

:::::: branch date: 9 hours ago
:::::: commit date: 4 weeks ago
config: riscv-randconfig-r073-20250731 (https://download.01.org/0day-ci/archive/20250731/[email protected]/config)
compiler: riscv64-linux-gcc (GCC) 8.5.0

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]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/irqchip/irq-riscv-imsic-platform.c:317 imsic_irqdomain_init() warn: variable dereferenced before check 'imsic' (see line 311)

vim +/imsic +317 drivers/irqchip/irq-riscv-imsic-platform.c

027e125acdbad7 Anup Patel   2024-03-07  307  
027e125acdbad7 Anup Patel   2024-03-07  308  int imsic_irqdomain_init(void)
027e125acdbad7 Anup Patel   2024-03-07  309  {
59422904dd9855 Marc Zyngier 2025-06-26  310  	struct irq_domain_info info = {
59422904dd9855 Marc Zyngier 2025-06-26 @311  		.fwnode		= imsic->fwnode,
59422904dd9855 Marc Zyngier 2025-06-26  312  		.ops		= &imsic_base_domain_ops,
59422904dd9855 Marc Zyngier 2025-06-26  313  		.host_data	= imsic,
59422904dd9855 Marc Zyngier 2025-06-26  314  	};
027e125acdbad7 Anup Patel   2024-03-07  315  	struct imsic_global_config *global;
027e125acdbad7 Anup Patel   2024-03-07  316  
027e125acdbad7 Anup Patel   2024-03-07 @317  	if (!imsic || !imsic->fwnode) {
027e125acdbad7 Anup Patel   2024-03-07  318  		pr_err("early driver not probed\n");
027e125acdbad7 Anup Patel   2024-03-07  319  		return -ENODEV;
027e125acdbad7 Anup Patel   2024-03-07  320  	}
027e125acdbad7 Anup Patel   2024-03-07  321  
027e125acdbad7 Anup Patel   2024-03-07  322  	if (imsic->base_domain) {
027e125acdbad7 Anup Patel   2024-03-07  323  		pr_err("%pfwP: irq domain already created\n", imsic->fwnode);
027e125acdbad7 Anup Patel   2024-03-07  324  		return -ENODEV;
027e125acdbad7 Anup Patel   2024-03-07  325  	}
027e125acdbad7 Anup Patel   2024-03-07  326  
027e125acdbad7 Anup Patel   2024-03-07  327  	/* Create Base IRQ domain */
59422904dd9855 Marc Zyngier 2025-06-26  328  	imsic->base_domain = msi_create_parent_irq_domain(&info, &imsic_msi_parent_ops);
027e125acdbad7 Anup Patel   2024-03-07  329  	if (!imsic->base_domain) {
027e125acdbad7 Anup Patel   2024-03-07  330  		pr_err("%pfwP: failed to create IMSIC base domain\n", imsic->fwnode);
027e125acdbad7 Anup Patel   2024-03-07  331  		return -ENOMEM;
027e125acdbad7 Anup Patel   2024-03-07  332  	}
027e125acdbad7 Anup Patel   2024-03-07  333  
027e125acdbad7 Anup Patel   2024-03-07  334  	global = &imsic->global;
027e125acdbad7 Anup Patel   2024-03-07  335  	pr_info("%pfwP:  hart-index-bits: %d,  guest-index-bits: %d\n",
027e125acdbad7 Anup Patel   2024-03-07  336  		imsic->fwnode, global->hart_index_bits, global->guest_index_bits);
027e125acdbad7 Anup Patel   2024-03-07  337  	pr_info("%pfwP: group-index-bits: %d, group-index-shift: %d\n",
027e125acdbad7 Anup Patel   2024-03-07  338  		imsic->fwnode, global->group_index_bits, global->group_index_shift);
4a1361e9a5c5db Andrew Jones 2024-09-09  339  	pr_info("%pfwP: per-CPU IDs %d at base address %pa\n",
027e125acdbad7 Anup Patel   2024-03-07  340  		imsic->fwnode, global->nr_ids, &global->base_addr);
027e125acdbad7 Anup Patel   2024-03-07  341  	pr_info("%pfwP: total %d interrupts available\n",
027e125acdbad7 Anup Patel   2024-03-07  342  		imsic->fwnode, num_possible_cpus() * (global->nr_ids - 1));
027e125acdbad7 Anup Patel   2024-03-07  343  
027e125acdbad7 Anup Patel   2024-03-07  344  	return 0;
027e125acdbad7 Anup Patel   2024-03-07  345  }
027e125acdbad7 Anup Patel   2024-03-07  346  

:::::: The code at line 317 was first introduced by commit
:::::: 027e125acdbad79e9a7274940e8bf92299b208af irqchip/riscv-imsic: Add device MSI domain support for platform devices

:::::: TO: Anup Patel <[email protected]>
:::::: CC: Thomas Gleixner <[email protected]>

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