DMA Engine development
 help / color / mirror / Atom feed
* [PATCH v2] dmaengine: ti: k3-udma-private: Fix refcount leak bug in  of_xudma_dev_get()
@ 2022-07-20  7:32 Liang He
  2022-09-05  6:23 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-07-20  7:32 UTC (permalink / raw)
  To: peter.ujfalusi, vkoul, dmaengine, windhl

We should call of_node_put() for the reference returned by
of_parse_phandle() in fail path or when it is not used anymore.
Here we only need to move the of_node_put() before the check.

Fixes: d70241913413 ("dmaengine: ti: k3-udma: Add glue layer for non DMAengine users")
Signed-off-by: Liang He <windhl@126.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
---
 changelog:

 v2: (1) add blank line based on Peter's advice
     (2) successfully compile the code based on Peter's explaination

 v1: https://lore.kernel.org/all/20220716084642.701268-1-windhl@126.com/

 drivers/dma/ti/k3-udma-private.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-private.c
index d4f1e4e9603a..85e00701473c 100644
--- a/drivers/dma/ti/k3-udma-private.c
+++ b/drivers/dma/ti/k3-udma-private.c
@@ -31,14 +31,14 @@ struct udma_dev *of_xudma_dev_get(struct device_node *np, const char *property)
 	}
 
 	pdev = of_find_device_by_node(udma_node);
+	if (np != udma_node)
+		of_node_put(udma_node);
+
 	if (!pdev) {
 		pr_debug("UDMA device not found\n");
 		return ERR_PTR(-EPROBE_DEFER);
 	}
 
-	if (np != udma_node)
-		of_node_put(udma_node);
-
 	ud = platform_get_drvdata(pdev);
 	if (!ud) {
 		pr_debug("UDMA has not been probed\n");
-- 
2.25.1


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

* Re: [PATCH v2] dmaengine: ti: k3-udma-private: Fix refcount leak bug in  of_xudma_dev_get()
  2022-07-20  7:32 [PATCH v2] dmaengine: ti: k3-udma-private: Fix refcount leak bug in of_xudma_dev_get() Liang He
@ 2022-09-05  6:23 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2022-09-05  6:23 UTC (permalink / raw)
  To: Liang He; +Cc: peter.ujfalusi, dmaengine

On 20-07-22, 15:32, Liang He wrote:
> We should call of_node_put() for the reference returned by
> of_parse_phandle() in fail path or when it is not used anymore.
> Here we only need to move the of_node_put() before the check.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2022-09-05  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-20  7:32 [PATCH v2] dmaengine: ti: k3-udma-private: Fix refcount leak bug in of_xudma_dev_get() Liang He
2022-09-05  6:23 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox