Skip to content

Commit 880799f

Browse files
minimaxwellKAGA-KOKO
authored andcommitted
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: 72e257c ("irqchip: Provide irq-msi-lib") Signed-off-by: Maxime Chevallier <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected] Closes: https://lore.kernel.org/all/[email protected]/
1 parent 71c8e2a commit 880799f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/irqchip/irq-msi-lib.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,16 @@ int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
128128
const struct msi_parent_ops *ops = d->msi_parent_ops;
129129
u32 busmask = BIT(bus_token);
130130

131+
if (!ops)
132+
return 0;
133+
131134
if (fwspec->fwnode != d->fwnode || fwspec->param_count != 0)
132135
return 0;
133136

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

138-
return ops && !!(ops->bus_select_mask & busmask);
141+
return !!(ops->bus_select_mask & busmask);
139142
}
140143
EXPORT_SYMBOL_GPL(msi_lib_irq_domain_select);

0 commit comments

Comments
 (0)