aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/hisilicon/hns3/hns3pf
diff options
context:
space:
mode:
authorGuojia Liao <liaoguojia@huawei.com>2020-01-04 10:49:29 +0800
committerDavid S. Miller <davem@davemloft.net>2020-01-06 13:26:25 -0800
commit2af8cb6126f36ffad848d1b0af714c09eb801b9d (patch)
tree2798cf814c1919bc9444c234dc0fb8fc4a2275c0 /drivers/net/ethernet/hisilicon/hns3/hns3pf
parentnet: hns3: modify the IRQ name of misc vectors (diff)
downloadlinux-dev-2af8cb6126f36ffad848d1b0af714c09eb801b9d.tar.xz
linux-dev-2af8cb6126f36ffad848d1b0af714c09eb801b9d.zip
net: hns3: add protection when get SFP speed as 0
In some case, the MAC speed get from hardware maybe 0, it should not be set to mac->speed. Signed-off-by: Guojia Liao <liaoguojia@huawei.com> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/hisilicon/hns3/hns3pf')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 4a15510a4bab..8bddda7f9092 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2835,6 +2835,12 @@ static int hclge_get_sfp_info(struct hclge_dev *hdev, struct hclge_mac *mac)
return ret;
}
+ /* In some case, mac speed get from IMP may be 0, it shouldn't be
+ * set to mac->speed.
+ */
+ if (!le32_to_cpu(resp->speed))
+ return 0;
+
mac->speed = le32_to_cpu(resp->speed);
/* if resp->speed_ability is 0, it means it's an old version
* firmware, do not update these params