提交 ca96feb9 编写于 作者: M Miaoqian Lin 提交者: Zheng Zengkai

net: ethernet: ti: am65-cpsw-nuss: Fix some refcount leaks

stable inclusion
from stable-v5.10.122
commit f7ba2cc57f404d2d9f26fb85bd3833d35a477829
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5W6OE

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f7ba2cc57f404d2d9f26fb85bd3833d35a477829

--------------------------------

[ Upstream commit 5dd89d2f ]

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: b1f66a5b ("net: ethernet: ti: am65-cpsw-nuss: enable packet timestamping support")
Fixes: 93a76530 ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
Signed-off-by: NMiaoqian Lin <linmq006@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 1325293e
...@@ -1716,6 +1716,7 @@ static int am65_cpsw_init_cpts(struct am65_cpsw_common *common) ...@@ -1716,6 +1716,7 @@ static int am65_cpsw_init_cpts(struct am65_cpsw_common *common)
if (IS_ERR(cpts)) { if (IS_ERR(cpts)) {
int ret = PTR_ERR(cpts); int ret = PTR_ERR(cpts);
of_node_put(node);
if (ret == -EOPNOTSUPP) { if (ret == -EOPNOTSUPP) {
dev_info(dev, "cpts disabled\n"); dev_info(dev, "cpts disabled\n");
return 0; return 0;
...@@ -2064,9 +2065,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) ...@@ -2064,9 +2065,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
if (!node) if (!node)
return -ENOENT; return -ENOENT;
common->port_num = of_get_child_count(node); common->port_num = of_get_child_count(node);
of_node_put(node);
if (common->port_num < 1 || common->port_num > AM65_CPSW_MAX_PORTS) if (common->port_num < 1 || common->port_num > AM65_CPSW_MAX_PORTS)
return -ENOENT; return -ENOENT;
of_node_put(node);
if (common->port_num != 1) if (common->port_num != 1)
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册