dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: plx_dma: add a missing put_device() on error path
@ 2021-03-23 13:19 Dan Carpenter
  2021-03-23 16:21 ` Logan Gunthorpe
  2021-04-12  9:44 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-03-23 13:19 UTC (permalink / raw)
  To: Logan Gunthorpe; +Cc: Vinod Koul, dmaengine, linux-kernel, kernel-janitors

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

Fixes: 905ca51e63be ("dmaengine: plx-dma: Introduce PLX DMA engine PCI driver skeleton")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/dma/plx_dma.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
index f387c5bbc170..166934544161 100644
--- a/drivers/dma/plx_dma.c
+++ b/drivers/dma/plx_dma.c
@@ -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);
@@ -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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: plx_dma: add a missing put_device() on error path
  2021-03-23 13:19 [PATCH] dmaengine: plx_dma: add a missing put_device() on error path Dan Carpenter
@ 2021-03-23 16:21 ` Logan Gunthorpe
  2021-04-12  9:44 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Logan Gunthorpe @ 2021-03-23 16:21 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Vinod Koul, dmaengine, linux-kernel, kernel-janitors



On 2021-03-23 7:19 a.m., Dan Carpenter wrote:
> Add a missing put_device(&pdev->dev) if the call to
> dma_async_device_register(dma); fails.
> 
> Fixes: 905ca51e63be ("dmaengine: plx-dma: Introduce PLX DMA engine PCI driver skeleton")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Good catch. Thanks Dan!

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Logan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: plx_dma: add a missing put_device() on error path
  2021-03-23 13:19 [PATCH] dmaengine: plx_dma: add a missing put_device() on error path Dan Carpenter
  2021-03-23 16:21 ` Logan Gunthorpe
@ 2021-04-12  9:44 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-04-12  9:44 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Logan Gunthorpe, dmaengine, linux-kernel, kernel-janitors

On 23-03-21, 16:19, Dan Carpenter wrote:
> Add a missing put_device(&pdev->dev) if the call to
> dma_async_device_register(dma); fails.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-12  9:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 13:19 [PATCH] dmaengine: plx_dma: add a missing put_device() on error path Dan Carpenter
2021-03-23 16:21 ` Logan Gunthorpe
2021-04-12  9:44 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).