diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 87ed504c260304e0065e6c4f9bb1c5d6ea5d26d9..293ba008bcef9aa57d8c010d00077478062f5fc7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2885,10 +2885,16 @@ static int hclge_get_status(struct hnae3_handle *handle) static struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf) { + if (pci_num_vf(hdev->pdev) == 0) { + dev_err(&hdev->pdev->dev, + "SRIOV is disabled, can not get vport(%d) info.\n", vf); + return NULL; + } + if (vf < 0 || vf >= pci_num_vf(hdev->pdev)) { dev_err(&hdev->pdev->dev, - "Out-of-range(1 < vfid < %d) or Invalid VF(=%d) specified.\n", - pci_num_vf(hdev->pdev), vf); + "vf id(%d) is out of range(0 <= vfid < %d)\n", + vf, pci_num_vf(hdev->pdev)); return NULL; }