* [PATCH] irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select
@ 2024-08-23 10:07 Maxime Chevallier
2024-08-23 12:03 ` [tip: irq/urgent] irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select() tip-bot2 for Maxime Chevallier
0 siblings, 1 reply; 2+ messages in thread
From: Maxime Chevallier @ 2024-08-23 10:07 UTC (permalink / raw)
To: Thomas Gleixner, Andrew Lunn, Gregory Clement,
Sebastian Hesselbarth, Russell King, Shivamurthy Shastri,
Anna-Maria Behnsen
Cc: Maxime Chevallier, linux-arm-kernel, linux-kernel,
Thomas Petazzoni
The irq_domain passed to msi_lib_irq_domain_select() may not have any
msi_parent_ops set. Move the test for NULL ops 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")
Closes: https://lore.kernel.org/all/20240821165034.1af97bad@fedora-3.home/
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
drivers/irqchip/irq-msi-lib.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c
index b5b90003311a..d8e29fc0d406 100644
--- a/drivers/irqchip/irq-msi-lib.c
+++ b/drivers/irqchip/irq-msi-lib.c
@@ -128,6 +128,9 @@ 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;
@@ -135,6 +138,6 @@ int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
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);
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip: irq/urgent] irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select()
2024-08-23 10:07 [PATCH] irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select Maxime Chevallier
@ 2024-08-23 12:03 ` tip-bot2 for Maxime Chevallier
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Maxime Chevallier @ 2024-08-23 12:03 UTC (permalink / raw)
To: linux-tip-commits
Cc: Maxime Chevallier, Thomas Gleixner, x86, linux-kernel, maz
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: 880799fc7a3a127c43143935c1a8767d77c19cae
Gitweb: https://git.kernel.org/tip/880799fc7a3a127c43143935c1a8767d77c19cae
Author: Maxime Chevallier <maxime.chevallier@bootlin.com>
AuthorDate: Fri, 23 Aug 2024 12:07:12 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 23 Aug 2024 13:55:15 +02:00
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/
---
drivers/irqchip/irq-msi-lib.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c
index b5b9000..d8e29fc 100644
--- a/drivers/irqchip/irq-msi-lib.c
+++ b/drivers/irqchip/irq-msi-lib.c
@@ -128,6 +128,9 @@ 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;
@@ -135,6 +138,6 @@ int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-23 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-23 10:07 [PATCH] irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select Maxime Chevallier
2024-08-23 12:03 ` [tip: irq/urgent] irqchip/irq-msi-lib: Check for NULL ops in msi_lib_irq_domain_select() tip-bot2 for Maxime Chevallier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox