Skip to content

Commit 0af2795

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
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: 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
1 parent feabeca commit 0af2795

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

kernel/irq/msi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,13 @@ int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev,
10841084
struct xarray *xa;
10851085
int ret, virq;
10861086

1087-
if (!msi_ctrl_valid(dev, &ctrl))
1088-
return -EINVAL;
1089-
10901087
msi_lock_descs(dev);
1088+
1089+
if (!msi_ctrl_valid(dev, &ctrl)) {
1090+
ret = -EINVAL;
1091+
goto unlock;
1092+
}
1093+
10911094
ret = msi_domain_add_simple_msi_descs(dev, &ctrl);
10921095
if (ret)
10931096
goto unlock;

0 commit comments

Comments
 (0)