summaryrefslogtreecommitdiff
path: root/kernel/irq
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2023-02-20 19:01:01 +0000
committerThomas Gleixner <tglx@linutronix.de>2023-02-20 22:29:54 +0100
commit0af2795f936f1ea1f9f1497447145dfcc7ed2823 (patch)
tree34f8f58dafce13a36072f518cd14f7ce02733743 /kernel/irq
parentfeabecaff5902f896531dde90646ca5dfa9d4f7d (diff)
downloadlwn-0af2795f936f1ea1f9f1497447145dfcc7ed2823.tar.gz
lwn-0af2795f936f1ea1f9f1497447145dfcc7ed2823.zip
genirq/msi: Take the per-device MSI lock before validating the control structure
Calling msi_ctrl_valid() ultimately results in calling msi_get_device_domain(), which requires holding the device MSI lock. However, in msi_domain_populate_irqs() the lock is taken right after having called msi_ctrl_valid(), which is just a tad too late. Take the lock before invoking msi_ctrl_valid(). 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> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/Y/Opu6ETe3ZzZ/8E@shell.armlinux.org.uk Link: https://lore.kernel.org/r/20230220190101.314446-1-maz@kernel.org
Diffstat (limited to 'kernel/irq')
-rw-r--r--kernel/irq/msi.c9
1 files 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;