Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7114596imm; Wed, 27 Jun 2018 20:43:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeL6Yj/CiKoW0DJt4Em9Kx+kxIcwejsi4qprGqbwp0GUYtOEC/tIVKng0zARVgrMCCa32OF X-Received: by 2002:a62:ff0c:: with SMTP id b12-v6mr8495191pfn.195.1530157392954; Wed, 27 Jun 2018 20:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530157392; cv=none; d=google.com; s=arc-20160816; b=DFkyOKrFCBAXMLgEu+T5hcFV38+bebp3O2iHzDkOLF4kuG/Ai0JnU4n1Q/gtNfGZdX WPFZgN+QpCGwvpSV8eT8n2PN4GWWAUVpftZGdxyBWm5m7O5likixEaQWNxCyZEt2Gmfz dbCFrOMgxvmmr0kp+OE0LBHKb2mRtl1I91CESIsssAyu7DABBvjDXfarzIkubJDKL8Bo 98OqDrYeQ1t81H+k3ToOzyXpr/OCaONtF6AIK8O/PaAT8Fx+ZjMKZAAtB+fPaBj/z3BH xpu6NnB7Z5R91G0vZTqkXXe3fkUg6xIHXuHSmnGvop/xIVHHYGIyiz/vrrOmuHrjf7yJ I2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=anfZms0I+wSUsoSQURe9/Hnuv2btvpcLOvQLWVIqk/A=; b=REUzzSRSoc3NGW6t6YKZcgIJUwIfWA47mSq40CCO35mnNA/hQYziKoNpLSUm6BWFcB KVatu+6QQcYab0kvEYyWg7KHdtKlfzYy2WW4fenyqd2fV9PyWBxsWoXKKpTwwF+R6SyB WwuuksvEf/6QDGDeXRo4aceJ93xZaYVeGJKtyLeFFDpka9V/lntGzlFQW/24+t7Gc/oy ak0ThEYQjHdKTUvmWP0MeyYkz4BcPWJwzSNizvmBnSgA4FjdVTToZpS2PScgb5yfXChX Rm7lv8MBHVyVrPwTRBY0xVqp1lg+QyPOkQM/gRaq223TG/9PDEmVddbzNlSR+6aVncYs Y3rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc5-v6si5600777plb.413.2018.06.27.20.42.58; Wed, 27 Jun 2018 20:43:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753379AbeF1DlY (ORCPT + 99 others); Wed, 27 Jun 2018 23:41:24 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9178 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753198AbeF1DlO (ORCPT ); Wed, 27 Jun 2018 23:41:14 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7D2D84E0064E5; Thu, 28 Jun 2018 11:40:58 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.382.0; Thu, 28 Jun 2018 11:40:52 +0800 From: Peng Li To: CC: , , , , , Subject: [PATCH net-next 03/11] net: hns3: add vector status check before free vector Date: Thu, 28 Jun 2018 12:12:21 +0800 Message-ID: <1530159149-122284-4-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530159149-122284-1-git-send-email-lipeng321@huawei.com> References: <1530159149-122284-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the hdev->vector_status[vector_id] is already HCLGE_INVALID_VPORT, should log the error and return. Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 ++++++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index d318d35..2b903f4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -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; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 3a8d7e0..1eb61c1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -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; -- 2.9.3