Skip to content

Commit 9e3d71a

Browse files
nehebkuba-moo
authored andcommitted
net: thunder_bgx: decrement cleanup index before use
All paths in probe that call goto defer do so before assigning phydev and thus it makes sense to cleanup the prior index. It also fixes a bug where index 0 does not get cleaned up. Fixes: b7d3e3d ("net: thunderx: Don't leak phy device references on -EPROBE_DEFER condition.") Signed-off-by: Rosen Penev <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9d28f94 commit 9e3d71a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/cavium/thunder/thunder_bgx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,11 +1519,11 @@ static int bgx_init_of_phy(struct bgx *bgx)
15191519
* for phy devices we may have already found.
15201520
*/
15211521
while (lmac) {
1522+
lmac--;
15221523
if (bgx->lmac[lmac].phydev) {
15231524
put_device(&bgx->lmac[lmac].phydev->mdio.dev);
15241525
bgx->lmac[lmac].phydev = NULL;
15251526
}
1526-
lmac--;
15271527
}
15281528
of_node_put(node);
15291529
return -EPROBE_DEFER;

0 commit comments

Comments
 (0)