]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: hns3: add vector status check before free vector
authorPeng Li <lipeng321@huawei.com>
Thu, 28 Jun 2018 04:12:21 +0000 (12:12 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Jun 2018 02:06:34 +0000 (11:06 +0900)
If the hdev->vector_status[vector_id] is already HCLGE_INVALID_VPORT,
should log the error and return.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

index d318d35e598fd61aa66406adb8048113f0252364..2b903f476149c21e137dea83fac408f0f6058c25 100644 (file)
@@ -2614,6 +2614,12 @@ static irqreturn_t hclge_misc_irq_handle(int irq, void *data)
 
 static void hclge_free_vector(struct hclge_dev *hdev, int vector_id)
 {
+       if (hdev->vector_status[vector_id] == HCLGE_INVALID_VPORT) {
+               dev_warn(&hdev->pdev->dev,
+                        "vector(vector_id %d) has been freed.\n", vector_id);
+               return;
+       }
+
        hdev->vector_status[vector_id] = HCLGE_INVALID_VPORT;
        hdev->num_msi_left += 1;
        hdev->num_msi_used -= 1;
index 3a8d7e0f4f56fc105506dbbb5335a4fe62ffab07..1eb61c126988270b05f6e230b539d9864913554f 100644 (file)
@@ -330,6 +330,12 @@ static int hclgevf_set_handle_info(struct hclgevf_dev *hdev)
 
 static void hclgevf_free_vector(struct hclgevf_dev *hdev, int vector_id)
 {
+       if (hdev->vector_status[vector_id] == HCLGEVF_INVALID_VPORT) {
+               dev_warn(&hdev->pdev->dev,
+                        "vector(vector_id %d) has been freed.\n", vector_id);
+               return;
+       }
+
        hdev->vector_status[vector_id] = HCLGEVF_INVALID_VPORT;
        hdev->num_msi_left += 1;
        hdev->num_msi_used -= 1;