]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: hns3: add protection when get SFP speed as 0
authorGuojia Liao <liaoguojia@huawei.com>
Sat, 4 Jan 2020 02:49:29 +0000 (10:49 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Jan 2020 21:26:25 +0000 (13:26 -0800)
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>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index 4a15510a4babbc05bfa349b9bfa468160310f3f7..8bddda7f9092076b560f8b8695917502ce251413 100644 (file)
@@ -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