linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy()
@ 2022-07-22 15:20 Liang He
  2022-07-22 17:38 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-07-22 15:20 UTC (permalink / raw)
  To: sgoutham, davem, edumazet, kuba, pabeni, linux-arm-kernel, 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.

Fixes: eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 2f6484dc186a..1e22cf76374f 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1494,10 +1494,13 @@ static int bgx_init_of_phy(struct bgx *bgx)
 		    !of_device_is_compatible(phy_np, "cortina,cs4223-slice")) {
 			/* Wait until the phy drivers are available */
 			pd = of_phy_find_device(phy_np);
-			if (!pd)
+			if (!pd) {
+				of_node_put(phy_np);
 				goto defer;
+			}
 			bgx->lmac[lmac].phydev = pd;
 		}
+		of_node_put(phy_np);
 
 		lmac++;
 		if (lmac == bgx->max_lmac) {
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy()
  2022-07-22 15:20 [PATCH] net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy() Liang He
@ 2022-07-22 17:38 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2022-07-22 17:38 UTC (permalink / raw)
  To: Liang He; +Cc: sgoutham, davem, edumazet, pabeni, linux-arm-kernel

On Fri, 22 Jul 2022 23:20:48 +0800 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.
> 
> Fixes: eee326fd8334 ("net: thunderx: bgx: Use standard firmware node infrastructure.")
> Signed-off-by: Liang He <windhl@126.com>

cc netdev@

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-07-22 17:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-22 15:20 [PATCH] net: thunder_bgx: Fix refcount leak bug in bgx_init_of_phy() Liang He
2022-07-22 17:38 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).