Skip to content

Commit

Permalink
genirq/msi: Take the per-device MSI lock before validating the contro…
Browse files Browse the repository at this point in the history
…l 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: 4074271 ("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
  • Loading branch information
Marc Zyngier authored and Thomas Gleixner committed Feb 20, 2023
1 parent feabeca commit 0af2795
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/irq/msi.c
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 0af2795

Please sign in to comment.