[PATCH] genirq/msi: Fix a duplicate issue for interrupt sysfs
From: Kunihiko Hayashi
Date: Mon Dec 27 2021 - 08:20:52 EST
The function msi_sysfs_populate_desc() has a for-loop with the number of
interrupts, and it is called inside a for-loop with the same interrupts
in __msi_domain_alloc_irqs().
So, msi_sysfs_populate_desc() is called multiple times for the same
descriptor, and a duplicate error for sysfs will occur. It should be
called out of the for-loop.
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Fixes: bf5e758f02fc ("genirq/msi: Simplify sysfs handling")
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@xxxxxxxxxxxxx>
---
kernel/irq/msi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 173bc04f9fe5..2f1c4ff8c683 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -887,12 +887,12 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
ret = msi_init_virq(domain, virq + i, vflags);
if (ret)
return ret;
+ }
- if (info->flags & MSI_FLAG_DEV_SYSFS) {
- ret = msi_sysfs_populate_desc(dev, desc);
- if (ret)
- return ret;
- }
+ if (info->flags & MSI_FLAG_DEV_SYSFS) {
+ ret = msi_sysfs_populate_desc(dev, desc);
+ if (ret)
+ return ret;
}
allocated++;
}
--
2.7.4