Skip to content

Commit c5ef83c

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns3: fix for phy_addr error in hclge_mac_mdio_config
When phy exists, phy_addr must less than PHY_MAX_ADDR. If not, hclge_mac_mdio_config should return error. And for fiber(phy_addr=0xff), it does not need hclge_mac_mdio_config. Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: Peng Li <[email protected]> Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ffd5656 commit c5ef83c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5503,11 +5503,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
55035503
goto err_sriov_disable;
55045504
}
55055505

5506-
ret = hclge_mac_mdio_config(hdev);
5507-
if (ret) {
5508-
dev_warn(&hdev->pdev->dev,
5509-
"mdio config fail ret=%d\n", ret);
5510-
goto err_sriov_disable;
5506+
if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) {
5507+
ret = hclge_mac_mdio_config(hdev);
5508+
if (ret) {
5509+
dev_err(&hdev->pdev->dev,
5510+
"mdio config fail ret=%d\n", ret);
5511+
goto err_sriov_disable;
5512+
}
55115513
}
55125514

55135515
ret = hclge_mac_init(hdev);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,11 @@ int hclge_mac_mdio_config(struct hclge_dev *hdev)
140140
struct mii_bus *mdio_bus;
141141
int ret;
142142

143-
if (hdev->hw.mac.phy_addr >= PHY_MAX_ADDR)
144-
return 0;
143+
if (hdev->hw.mac.phy_addr >= PHY_MAX_ADDR) {
144+
dev_err(&hdev->pdev->dev, "phy_addr(%d) is too large.\n",
145+
hdev->hw.mac.phy_addr);
146+
return -EINVAL;
147+
}
145148

146149
mdio_bus = devm_mdiobus_alloc(&hdev->pdev->dev);
147150
if (!mdio_bus)

0 commit comments

Comments
 (0)