Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/powernv/pci: Fix underflow and leak issue

pnv_irq_domain_alloc() allocates interrupts at parent's interrupt
domain. If it fails in the progress, all allocated interrupts are
freed.

The number of successfully allocated interrupts so far is stored
"i". However, "i - 1" interrupts are freed. This is broken:

- One interrupt is not be freed

- If "i" is zero, "i - 1" wraps around

Correct the number of freed interrupts to "i".

Fixes: 0fcfe2247e75 ("powerpc/powernv/pci: Add MSI domains")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: stable@vger.kernel.org
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/70f8debe8688e0b467367db769b71c20146a836d.1754300646.git.namcao@linutronix.de

authored by

Nam Cao and committed by
Madhavan Srinivasan
a3908790 3443ff3b

+1 -1
+1 -1
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1854 1854 return 0; 1855 1855 1856 1856 out: 1857 - irq_domain_free_irqs_parent(domain, virq, i - 1); 1857 + irq_domain_free_irqs_parent(domain, virq, i); 1858 1858 msi_bitmap_free_hwirqs(&phb->msi_bmp, hwirq, nr_irqs); 1859 1859 return ret; 1860 1860 }