Commit 07503e6a authored by Dan Carpenter's avatar Dan Carpenter Committed by Vinod Koul

dmaengine: plx_dma: add a missing put_device() on error path

Add a missing put_device(&pdev->dev) if the call to
dma_async_device_register(dma); fails.

Fixes: 905ca51e ("dmaengine: plx-dma: Introduce PLX DMA engine PCI driver skeleton")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarLogan Gunthorpe <logang@deltatee.com>
Link: https://lore.kernel.org/r/YFnq/0IQzixtAbC1@mwandaSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 917a3200
...@@ -507,10 +507,8 @@ static int plx_dma_create(struct pci_dev *pdev) ...@@ -507,10 +507,8 @@ static int plx_dma_create(struct pci_dev *pdev)
rc = request_irq(pci_irq_vector(pdev, 0), plx_dma_isr, 0, rc = request_irq(pci_irq_vector(pdev, 0), plx_dma_isr, 0,
KBUILD_MODNAME, plxdev); KBUILD_MODNAME, plxdev);
if (rc) { if (rc)
kfree(plxdev); goto free_plx;
return rc;
}
spin_lock_init(&plxdev->ring_lock); spin_lock_init(&plxdev->ring_lock);
tasklet_setup(&plxdev->desc_task, plx_dma_desc_task); tasklet_setup(&plxdev->desc_task, plx_dma_desc_task);
...@@ -540,14 +538,20 @@ static int plx_dma_create(struct pci_dev *pdev) ...@@ -540,14 +538,20 @@ static int plx_dma_create(struct pci_dev *pdev)
rc = dma_async_device_register(dma); rc = dma_async_device_register(dma);
if (rc) { if (rc) {
pci_err(pdev, "Failed to register dma device: %d\n", rc); pci_err(pdev, "Failed to register dma device: %d\n", rc);
free_irq(pci_irq_vector(pdev, 0), plxdev); goto put_device;
kfree(plxdev);
return rc;
} }
pci_set_drvdata(pdev, plxdev); pci_set_drvdata(pdev, plxdev);
return 0; return 0;
put_device:
put_device(&pdev->dev);
free_irq(pci_irq_vector(pdev, 0), plxdev);
free_plx:
kfree(plxdev);
return rc;
} }
static int plx_dma_probe(struct pci_dev *pdev, static int plx_dma_probe(struct pci_dev *pdev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment