Skip to content

Commit

Permalink
genirq/msi: Fix off-by-one error in msi_domain_alloc()
Browse files Browse the repository at this point in the history
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: f3cf8bb ("genirq: Add generic msi irq domain support")
Signed-off-by: Jinjie Ruan <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/all/[email protected]
  • Loading branch information
Jinjie Ruan authored and KAGA-KOKO committed Oct 27, 2024
1 parent 42f7652 commit 5f994f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/irq/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5f994f5

Please sign in to comment.