lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241028-ti-dma-crossbar-put_device-v1-1-e8087e1f0a59@gmail.com>
Date: Mon, 28 Oct 2024 20:03:36 +0100
From: Javier Carrasco <javier.carrasco.cruz@...il.com>
To: Peter Ujfalusi <peter.ujfalusi@...il.com>, 
 Vinod Koul <vkoul@...nel.org>
Cc: Peter Ujfalusi <peter.ujfalusi@...com>, dmaengine@...r.kernel.org, 
 linux-kernel@...r.kernel.org, stable@...r.kernel.org, 
 Javier Carrasco <javier.carrasco.cruz@...il.com>
Subject: [PATCH] dmaengine: ti: dma-crossbar: Add missing put_device in
 ti_am335x_xbar_route_allocate

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@...r.kernel.org
Fixes: 42dbdcc6bf96 ("dmaengine: ti-dma-crossbar: Add support for crossbar on AM33xx/AM43xx")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@...il.com>
---
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@...il.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ