Skip to content

Commit 3aac7ad

Browse files
windhlkuba-moo
authored andcommitted
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: 52323ef ("net: marvell: prestera: add phylink support") Signed-off-by: Liang He <[email protected]> Reviewed-by: Yevhen Orlov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c2e1cfe commit 3aac7ad

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/ethernet/marvell/prestera/prestera_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)
368368
if (!sw->np)
369369
return 0;
370370

371+
of_node_get(sw->np);
371372
ports = of_find_node_by_name(sw->np, "ports");
372373

373374
for_each_child_of_node(ports, node) {
@@ -417,6 +418,7 @@ static int prestera_port_sfp_bind(struct prestera_port *port)
417418
}
418419

419420
out:
421+
of_node_put(node);
420422
of_node_put(ports);
421423
return err;
422424
}

0 commit comments

Comments
 (0)