Skip to content

Commit

Permalink
dmaengine: plx_dma: add a missing put_device() on error path
Browse files Browse the repository at this point in the history
Add a missing put_device(&pdev->dev) if the call to
dma_async_device_register(dma); fails.

Fixes: 905ca51 ("dmaengine: plx-dma: Introduce PLX DMA engine PCI driver skeleton")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Link: https://lore.kernel.org/r/YFnq/0IQzixtAbC1@mwanda
Signed-off-by: Vinod Koul <vkoul@kernel.org>
  • Loading branch information
Dan Carpenter authored and Vinod Koul committed Apr 12, 2021
1 parent 917a320 commit 07503e6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions drivers/dma/plx_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
KBUILD_MODNAME, plxdev);
if (rc) {
kfree(plxdev);
return rc;
}
if (rc)
goto free_plx;

spin_lock_init(&plxdev->ring_lock);
tasklet_setup(&plxdev->desc_task, plx_dma_desc_task);
Expand Down Expand Up @@ -540,14 +538,20 @@ static int plx_dma_create(struct pci_dev *pdev)
rc = dma_async_device_register(dma);
if (rc) {
pci_err(pdev, "Failed to register dma device: %d\n", rc);
free_irq(pci_irq_vector(pdev, 0), plxdev);
kfree(plxdev);
return rc;
goto put_device;
}

pci_set_drvdata(pdev, plxdev);

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,
Expand Down

0 comments on commit 07503e6

Please sign in to comment.