Skip to content

Commit

Permalink
irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select()
Browse files Browse the repository at this point in the history
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: 72e257c ("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/
  • Loading branch information
Maxime Chevallier authored and Thomas Gleixner committed Aug 23, 2024
1 parent 71c8e2a commit 880799f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/irqchip/irq-msi-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
const struct msi_parent_ops *ops = d->msi_parent_ops;
u32 busmask = BIT(bus_token);

if (!ops)
return 0;

if (fwspec->fwnode != d->fwnode || fwspec->param_count != 0)
return 0;

/* Handle pure domain searches */
if (bus_token == ops->bus_select_token)
return 1;

return ops && !!(ops->bus_select_mask & busmask);
return !!(ops->bus_select_mask & busmask);
}
EXPORT_SYMBOL_GPL(msi_lib_irq_domain_select);

0 comments on commit 880799f

Please sign in to comment.