[PATCH] fix: net: ti: cpsw_init_common: fix excess of_node_put on parent node when cpts child not found
From: WenTao Liang
Date: Fri Jun 26 2026 - 11:33:09 EST
When no "cpts" child node exists in the device tree, cpts_node is
assigned cpsw->dev->of_node without taking a reference via of_node_get.
The function then unconditionally calls of_node_put(cpts_node) at the
end, causing an excess put on the parent device node which can lead to a
refcount underflow.
Use of_node_get when falling back to the parent node to ensure the
reference count is properly balanced with the subsequent of_node_put.
Cc: stable@xxxxxxxxxxxxxxx
Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac")
Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
---
drivers/net/ethernet/ti/cpsw_priv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index 1f6f374551cb..b20567f96d78 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -553,7 +553,7 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem *ss_regs,
cpts_node = of_get_child_by_name(cpsw->dev->of_node, "cpts");
if (!cpts_node)
- cpts_node = cpsw->dev->of_node;
+ cpts_node = of_node_get(cpsw->dev->of_node);
cpsw->cpts = cpts_create(cpsw->dev, cpts_regs, cpts_node,
CPTS_N_ETX_TS);
--
2.39.5 (Apple Git-154)