]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
genirq/msi: Fix off-by-one error in msi_domain_alloc()
authorJinjie Ruan <ruanjinjie@huawei.com>
Sat, 26 Oct 2024 06:36:39 +0000 (14:36 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 27 Oct 2024 09:40:47 +0000 (10:40 +0100)
The error path in msi_domain_alloc(), frees the already allocated MSI
interrupts in a loop, but the loop condition terminates when the index
reaches zero, which fails to free the first allocated MSI interrupt at
index zero.

Check for >= 0 so that msi[0] is freed as well.

Fixes: f3cf8bb0d6c3 ("genirq: Add generic msi irq domain support")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241026063639.10711-1-ruanjinjie@huawei.com
kernel/irq/msi.c

index 3a24d6b5f559ca4b2416104a3d346b0e88172ac8..396a067a8a56b59c54f5b478acd6d68a19faba89 100644 (file)
@@ -718,7 +718,7 @@ static int msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
                ret = ops->msi_init(domain, info, virq + i, hwirq + i, arg);
                if (ret < 0) {
                        if (ops->msi_free) {
-                               for (i--; i > 0; i--)
+                               for (i--; i >= 0; i--)
                                        ops->msi_free(domain, info, virq + i);
                        }
                        irq_domain_free_irqs_top(domain, virq, nr_irqs);