[PATCH] dmaengine: ti: dma-crossbar: Add missing put_device in ti_am335x_xbar_route_allocate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The refcount of the device obtained with of_find_device_by_node() must
be decremented when the device is no longer required. Add the missing
calls to put_device(&pdev->dev) in the error paths of
ti_am335x_xbar_route_allocate().

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 42dbdcc6bf96 ("dmaengine: ti-dma-crossbar: Add support for crossbar on AM33xx/AM43xx")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
---
Similar to what commit 615a4bfc426e ("dmaengine: ti: Add missing
put_device in ti_dra7_xbar_route_allocate") did for dra7, where the
calls to put_device were also missing in the error paths.
---
 drivers/dma/ti/dma-crossbar.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ti/dma-crossbar.c b/drivers/dma/ti/dma-crossbar.c
index 7f17ee87a6dc..ae596b3fc636 100644
--- a/drivers/dma/ti/dma-crossbar.c
+++ b/drivers/dma/ti/dma-crossbar.c
@@ -81,18 +81,22 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
 	struct ti_am335x_xbar_data *xbar = platform_get_drvdata(pdev);
 	struct ti_am335x_xbar_map *map;
 
-	if (dma_spec->args_count != 3)
+	if (dma_spec->args_count != 3) {
+		put_device(&pdev->dev);
 		return ERR_PTR(-EINVAL);
+	}
 
 	if (dma_spec->args[2] >= xbar->xbar_events) {
 		dev_err(&pdev->dev, "Invalid XBAR event number: %d\n",
 			dma_spec->args[2]);
+		put_device(&pdev->dev);
 		return ERR_PTR(-EINVAL);
 	}
 
 	if (dma_spec->args[0] >= xbar->dma_requests) {
 		dev_err(&pdev->dev, "Invalid DMA request line number: %d\n",
 			dma_spec->args[0]);
+		put_device(&pdev->dev);
 		return ERR_PTR(-EINVAL);
 	}
 
@@ -100,12 +104,14 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
 	dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
 	if (!dma_spec->np) {
 		dev_err(&pdev->dev, "Can't get DMA master\n");
+		put_device(&pdev->dev);
 		return ERR_PTR(-EINVAL);
 	}
 
 	map = kzalloc(sizeof(*map), GFP_KERNEL);
 	if (!map) {
 		of_node_put(dma_spec->np);
+		put_device(&pdev->dev);
 		return ERR_PTR(-ENOMEM);
 	}
 

---
base-commit: dec9255a128e19c5fcc3bdb18175d78094cc624d
change-id: 20241028-ti-dma-crossbar-put_device-39ebab498011

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>





[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux