From: Miaoqian Lin Date: Thu, 26 May 2022 08:52:08 +0000 (+0400) Subject: net: ethernet: ti: am65-cpsw-nuss: Fix some refcount leaks X-Git-Tag: baikal/aarch64/sdk6.1~3836^2~42 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=eb1324f1fa3f369ec87b1c34107a0f1370c39c44;p=kernel.git net: ethernet: ti: am65-cpsw-nuss: Fix some refcount leaks of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. am65_cpsw_init_cpts() and am65_cpsw_nuss_probe() don't release the refcount in error case. Add missing of_node_put() to avoid refcount leak. Fixes: 1448b012fa6c ("net: ethernet: ti: am65-cpsw-nuss: enable packet timestamping support") Fixes: e7364a21077b ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver") Signed-off-by: Miaoqian Lin Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 77bdda97b2b08..fb92d4c1547db 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -1789,6 +1789,7 @@ static int am65_cpsw_init_cpts(struct am65_cpsw_common *common) if (IS_ERR(cpts)) { int ret = PTR_ERR(cpts); + of_node_put(node); if (ret == -EOPNOTSUPP) { dev_info(dev, "cpts disabled\n"); return 0; @@ -2665,9 +2666,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) if (!node) return -ENOENT; common->port_num = of_get_child_count(node); + of_node_put(node); if (common->port_num < 1 || common->port_num > AM65_CPSW_MAX_PORTS) return -ENOENT; - of_node_put(node); common->rx_flow_id_base = -1; init_completion(&common->tdown_complete);