diff mbox series

[04/10] of: Fix refcount leakage for OF node returned by __of_get_dma_parent()

Message ID 20241206-of_core_fix-v1-4-dc28ed56bec3@quicinc.com
State Accepted
Headers show
Series of: fix bugs and improve codes | expand

Checks

Context Check Description
robh/checkpatch warning total: 0 errors, 1 warnings, 8 lines checked
robh/patch-applied fail build log

Commit Message

Zijun Hu Dec. 6, 2024, 12:52 a.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

__of_get_dma_parent() returns OF device node @args.np, but the node's
refcount is increased twice, by both of_parse_phandle_with_args() and
of_node_get(), so causes refcount leakage for the node.

Fix by directly returning the node got by of_parse_phandle_with_args().

Fixes: f83a6e5dea6c ("of: address: Add support for the parent DMA bus")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/of/address.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rob Herring Dec. 9, 2024, 8:32 p.m. UTC | #1
On Fri, Dec 06, 2024 at 08:52:30AM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> __of_get_dma_parent() returns OF device node @args.np, but the node's
> refcount is increased twice, by both of_parse_phandle_with_args() and
> of_node_get(), so causes refcount leakage for the node.
> 
> Fix by directly returning the node got by of_parse_phandle_with_args().
> 
> Fixes: f83a6e5dea6c ("of: address: Add support for the parent DMA bus")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  drivers/of/address.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Rob
diff mbox series

Patch

diff --git a/drivers/of/address.c b/drivers/of/address.c
index c5b925ac469f16b8ae4b8275b60210a2d583ff83..cda1cbb82eabdcd39d32446023fbb105b69bc99d 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -619,7 +619,7 @@  struct device_node *__of_get_dma_parent(const struct device_node *np)
 	if (ret < 0)
 		return of_get_parent(np);
 
-	return of_node_get(args.np);
+	return args.np;
 }
 #endif