From: Zijun Hu Date: Fri, 6 Dec 2024 00:52:30 +0000 (+0800) Subject: of: Fix refcount leakage for OF node returned by __of_get_dma_parent() X-Git-Tag: v6.1.122~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28ca6f1d191365c568eace3d433e6288cd7cf57d;p=thirdparty%2Fkernel%2Fstable.git of: Fix refcount leakage for OF node returned by __of_get_dma_parent() commit 5d009e024056ded20c5bb1583146b833b23bbd5a upstream. __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 Link: https://lore.kernel.org/r/20241206-of_core_fix-v1-4-dc28ed56bec3@quicinc.com Signed-off-by: Rob Herring (Arm) Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/of/address.c b/drivers/of/address.c index 67763e5b8c0ef..18498619177c6 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -595,7 +595,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