aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang He <windhl@126.com>2022-09-21 21:32:45 +0800
committerJakub Kicinski <kuba@kernel.org>2022-09-22 07:23:58 -0700
commit3aac7ada64d8c26ccc922f1ca966043c0dae88da (patch)
tree9f4e5c6aeffd666c4f87cffb270c8040b6418b42
parentc2e1cfefcac35e0eea229e148c8284088ce437b5 (diff)
downloadlinux-trace-3aac7ada64d8c26ccc922f1ca966043c0dae88da.tar.gz
net: marvell: Fix refcounting bugs in prestera_port_sfp_bind()
In prestera_port_sfp_bind(), there are two refcounting bugs: (1) we should call of_node_get() before of_find_node_by_name() as it will automaitcally decrease the refcount of 'from' argument; (2) we should call of_node_put() for the break of the iteration for_each_child_of_node() as it will automatically increase and decrease the 'child'. Fixes: 52323ef75414 ("net: marvell: prestera: add phylink support") Signed-off-by: Liang He <windhl@126.com> Reviewed-by: Yevhen Orlov <yevhen.orlov@plvision.eu> Link: https://lore.kernel.org/r/20220921133245.4111672-1-windhl@126.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/ethernet/marvell/prestera/prestera_main.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index ede3e53b97901a..a895862b48212f 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -368,6 +368,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)
if (!sw->np)
return 0;
+ of_node_get(sw->np);
ports = of_find_node_by_name(sw->np, "ports");
for_each_child_of_node(ports, node) {
@@ -417,6 +418,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)
}
out:
+ of_node_put(node);
of_node_put(ports);
return err;
}