Commit 2af8cb61 authored by Guojia Liao's avatar Guojia Liao Committed by David S. Miller

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: default avatarGuojia Liao <liaoguojia@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f97c4d82
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment