public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Liang He <windhl@126.com>
To: peter.ujfalusi@gmail.com, vkoul@kernel.org,
	dmaengine@vger.kernel.org, windhl@126.com
Subject: [PATCH] dmaengine: ti: k3-udma-private: Fix refcount leak bug in of_xudma_dev_get()
Date: Sat, 16 Jul 2022 16:46:42 +0800	[thread overview]
Message-ID: <20220716084642.701268-1-windhl@126.com> (raw)

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>
---

I cannot find the 'k3-udma-private.c' comiple item in drivers/dma/ti/Makefile, 
I wonder if the author has forgotten the compile item and the
k3-udma-private.c has not been compiled before.

I have tried to add k3-udma-private.o in the Makefile, but there are lots of
compile errors.  
Please check it carefully and if possbile please teach me how to compile it, thanks.


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

diff --git a/drivers/dma/ti/k3-udma-private.c b/drivers/dma/ti/k3-udma-private.c
index d4f1e4e9603a..ec274ef7d5ea 100644
--- a/drivers/dma/ti/k3-udma-private.c
+++ b/drivers/dma/ti/k3-udma-private.c
@@ -31,14 +31,13 @@ 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


             reply	other threads:[~2022-07-16  8:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16  8:46 Liang He [this message]
2022-07-20  6:39 ` [PATCH] dmaengine: ti: k3-udma-private: Fix refcount leak bug in of_xudma_dev_get() Péter Ujfalusi
2022-07-20  6:54   ` Liang He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220716084642.701268-1-windhl@126.com \
    --to=windhl@126.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=peter.ujfalusi@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox