Commit 3aac7ada authored by Liang He's avatar Liang He Committed by Jakub Kicinski

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: 52323ef7 ("net: marvell: prestera: add phylink support")
Signed-off-by: default avatarLiang He <windhl@126.com>
Reviewed-by: default avatarYevhen Orlov <yevhen.orlov@plvision.eu>
Link: https://lore.kernel.org/r/20220921133245.4111672-1-windhl@126.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c2e1cfef
...@@ -368,6 +368,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port) ...@@ -368,6 +368,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)
if (!sw->np) if (!sw->np)
return 0; return 0;
of_node_get(sw->np);
ports = of_find_node_by_name(sw->np, "ports"); ports = of_find_node_by_name(sw->np, "ports");
for_each_child_of_node(ports, node) { for_each_child_of_node(ports, node) {
...@@ -417,6 +418,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port) ...@@ -417,6 +418,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)
} }
out: out:
of_node_put(node);
of_node_put(ports); of_node_put(ports);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment