Re: [PATCH v3 06/11] dmaengine: switchtec-dma: fix chan_status_irq cleanup on create() error
Frank Li <[email protected]> Mon, 27 Jul 2026 16:55:40 -0400
| Newsgroups | org.kernel.vger.dmaengine,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <amfFzMyBpD5sQw6u@lizhi-Precision-Tower-5810> |
On Mon, Jul 27, 2026 at 12:15:21PM -0600, Logan Gunthorpe wrote: > chan_status_irq stores an MSI-X vector index, but err_exit freed it > with plain free_irq() instead of pci_free_irq(), which would free the > wrong Linux IRQ. The guard also treated a valid vector index of 0 as > unset, skipping the free entirely in that case and leaving the handler > registered against soon-to-be-freed swdma_dev. > > Initialize chan_status_irq to -1 and use the value being non-negative > to signal when to free it with pci_free_irq(). > > Reported-by: Sashiko <[email protected]> > Link: https://lore.kernel.org/dmaengine/[email protected] > Signed-off-by: Logan Gunthorpe <[email protected]> > --- Reviewed-by: Frank Li <[email protected]> > drivers/dma/switchtec_dma.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/dma/switchtec_dma.c b/drivers/dma/switchtec_dma.c > index c752a1b05871..31feb2816e79 100644 > --- a/drivers/dma/switchtec_dma.c > +++ b/drivers/dma/switchtec_dma.c > @@ -1248,6 +1248,8 @@ static int switchtec_dma_create(struct pci_dev *pdev) > if (!swdma_dev) > return -ENOMEM; > > + swdma_dev->chan_status_irq = -1; > + > swdma_dev->bar = ioremap(pci_resource_start(pdev, 0), > pci_resource_len(pdev, 0)); > > @@ -1322,8 +1324,8 @@ static int switchtec_dma_create(struct pci_dev *pdev) > switchtec_dma_chans_free(swdma_dev); > > err_exit: > - if (swdma_dev->chan_status_irq) > - free_irq(swdma_dev->chan_status_irq, swdma_dev); > + if (swdma_dev->chan_status_irq >= 0) > + pci_free_irq(pdev, swdma_dev->chan_status_irq, swdma_dev); > > iounmap(swdma_dev->bar); > kfree(swdma_dev); > -- > 2.47.3 >