Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select()

The irq_domain passed to msi_lib_irq_domain_select() may not have
msi_parent_ops set. There is a NULL pointer check for it, but unfortunately
there is a dereference of the parent ops pointer before that.

Move the NULL pointer test before the first use of that pointer.

This was found on a MacchiatoBin (Marvell Armada 8K SoC), which uses the
irq-mvebu-sei driver.

Fixes: 72e257c6f058 ("irqchip: Provide irq-msi-lib")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20240823100733.1900666-1-maxime.chevallier@bootlin.com
Closes: https://lore.kernel.org/all/20240821165034.1af97bad@fedora-3.home/

authored by

Maxime Chevallier and committed by
Thomas Gleixner
880799fc 71c8e2a7

+4 -1
+4 -1
drivers/irqchip/irq-msi-lib.c
··· 128 128 const struct msi_parent_ops *ops = d->msi_parent_ops; 129 129 u32 busmask = BIT(bus_token); 130 130 131 + if (!ops) 132 + return 0; 133 + 131 134 if (fwspec->fwnode != d->fwnode || fwspec->param_count != 0) 132 135 return 0; 133 136 ··· 138 135 if (bus_token == ops->bus_select_token) 139 136 return 1; 140 137 141 - return ops && !!(ops->bus_select_mask & busmask); 138 + return !!(ops->bus_select_mask & busmask); 142 139 } 143 140 EXPORT_SYMBOL_GPL(msi_lib_irq_domain_select);