* [PATCH] genirq/msi: Take the per-device MSI lock before validating the control structure
@ 2023-02-20 19:01 Marc Zyngier
2023-02-20 19:05 ` Russell King (Oracle)
0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2023-02-20 19:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Thomas Gleixner, Russell King (Oracle), stable
Calling msi_ctrl_valid() ultimately results in calling
msi_get_device_domain(), which requires holding the device MSI lock.
However, we take that lock right after having called msi_ctrl_valid(),
which is just a tad too late. Taking the lock earlier solves the issue.
Fixes: 40742716f294 ("genirq/msi: Make msi_add_simple_msi_descs() device domain aware")
Reported-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/Y/Opu6ETe3ZzZ/8E@shell.armlinux.org.uk
---
kernel/irq/msi.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 783a3e6a0b10..13d96495e6d0 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -1084,10 +1084,13 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
struct xarray *xa;
int ret, virq;
- if (!msi_ctrl_valid(dev, &ctrl))
- return -EINVAL;
-
msi_lock_descs(dev);
+
+ if (!msi_ctrl_valid(dev, &ctrl)) {
+ ret = -EINVAL;
+ goto unlock;
+ }
+
ret = msi_domain_add_simple_msi_descs(dev, &ctrl);
if (ret)
goto unlock;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] genirq/msi: Take the per-device MSI lock before validating the control structure
2023-02-20 19:01 [PATCH] genirq/msi: Take the per-device MSI lock before validating the control structure Marc Zyngier
@ 2023-02-20 19:05 ` Russell King (Oracle)
0 siblings, 0 replies; 2+ messages in thread
From: Russell King (Oracle) @ 2023-02-20 19:05 UTC (permalink / raw)
To: Marc Zyngier; +Cc: linux-kernel, Thomas Gleixner, stable
On Mon, Feb 20, 2023 at 07:01:01PM +0000, Marc Zyngier wrote:
> Calling msi_ctrl_valid() ultimately results in calling
> msi_get_device_domain(), which requires holding the device MSI lock.
>
> However, we take that lock right after having called msi_ctrl_valid(),
> which is just a tad too late. Taking the lock earlier solves the issue.
>
> Fixes: 40742716f294 ("genirq/msi: Make msi_add_simple_msi_descs() device domain aware")
> Reported-by: "Russell King (Oracle)" <linux@armlinux.org.uk>
Tested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thanks!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-20 19:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 19:01 [PATCH] genirq/msi: Take the per-device MSI lock before validating the control structure Marc Zyngier
2023-02-20 19:05 ` Russell King (Oracle)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.