@@ -1469,6 +1469,7 @@ static int bgx_init_of_phy(struct bgx *bgx)
struct fwnode_handle *fwn;
struct device_node *node = NULL;
u8 lmac = 0;
+ int err = 0;
device_for_each_child_node(&bgx->pdev->dev, fwn) {
struct phy_device *pd;
@@ -1479,7 +1480,7 @@ static int bgx_init_of_phy(struct bgx *bgx)
*/
node = to_of_node(fwn);
if (!node)
- break;
+ goto out_handle_put;
of_get_mac_address(node, bgx->lmac[lmac].mac);
@@ -1501,10 +1502,8 @@ static int bgx_init_of_phy(struct bgx *bgx)
}
lmac++;
- if (lmac == bgx->max_lmac) {
- of_node_put(node);
- break;
- }
+ if (lmac == bgx->max_lmac)
+ goto out_node_put;
}
return 0;
@@ -1519,8 +1518,12 @@ static int bgx_init_of_phy(struct bgx *bgx)
}
lmac--;
}
+ err = -EPROBE_DEFER;
+out_node_put:
of_node_put(node);
- return -EPROBE_DEFER;
+out_handle_put:
+ fwnode_handle_put(fwn);
+ return err;
}
#else