Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp271272imu; Fri, 14 Dec 2018 19:19:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xsy5HfLTmHwDxGj3JMVWfuHJ10E1gPJjG0J7FRXJolG7oJJZeKEhD6+PmzJIOw22Jz5uTq X-Received: by 2002:a62:a510:: with SMTP id v16mr5190118pfm.18.1544843980943; Fri, 14 Dec 2018 19:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544843980; cv=none; d=google.com; s=arc-20160816; b=YEZFoKFMwn7RfGkJJJicPu6XbSOhKCsBrz4Oc9FurPJvWyUfEfpP2LVyQzBlketZzY qUuOy4yT4u/U/bmsOus4WiPNse4IleaOb0+OE7AHYJ/dFgNbgBil9LSorl78S9hZF7Y3 2ETP30sO4xxh8l6cX/+GwZt5LVdS89hj7vjrV0cau6gZDjL4lN61oF5y+RYt+XnYDmxC 8Z9dLyqRNBQ/ygGhuo5+mSpO0fogCFg47GuGsm8uOk6L/roNLXkwfIhzrTAYM4hU14fc NvwAgUOQB9BRIgrqOVCjZyeXBlxUMeiKmadmr2AzskzILwOvYLlBFc+papMLqX6i01+j RBzQ== 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; bh=q2U2eyzm2z5ErZ/VCSP9E1qp+OtDrn48kaczb9Ga5xY=; b=xKfYDJhzgiom+GDu83+7rpneprQ9xgMGcsZICecGEBLCO05vRZwPNSEfXoOJGKlktW FcO8197k9t4fWQ/E0VBYsqlIU5eENwDaYUuEIvVU0USeja+V22+vYz2GI49278hv/L4o BXzVshWwlVzJtCW7NHI4igCpe7mICvLkFqXqvNNCTqbE2MmUeiGxb36ztWA6zkj4j2g7 ILhg9q4UGBZOemJjXhvU3ZfBYbQBfZm2tKGlKByj+XfyuKJYYvMc1voU7JIL5L5JI6p/ jU4dyZhzuXkKtQUVSAzUpw0PgHqH9DGg7pLh4kChxVoYcUTFBT1z+tcAlfg2dFWQodgd HnXQ== 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 q9si5559381pgi.89.2018.12.14.19.19.14; Fri, 14 Dec 2018 19:19:40 -0800 (PST) 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 S1730539AbeLODSE (ORCPT + 99 others); Fri, 14 Dec 2018 22:18:04 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16137 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729906AbeLODRe (ORCPT ); Fri, 14 Dec 2018 22:17:34 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 096C6966CA26; Sat, 15 Dec 2018 11:17:30 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Sat, 15 Dec 2018 11:17:23 +0800 From: Peng Li To: CC: , , , , , Subject: [Patch net 06/10] net: hns: Free irq when exit from abnormal branch Date: Sat, 15 Dec 2018 11:53:25 +0800 Message-ID: <1544846009-50276-7-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> References: <1544846009-50276-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 From: Yonglong Liu 1.In "hns_nic_init_irq", if request irq fail at index i, the function return directly without releasing irq resources that already requested. 2.In "hns_nic_net_up" after "hns_nic_init_irq", if exceptional branch occurs, irqs that already requested are not release. Signed-off-by: Yonglong Liu Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index c9454c4..03d959c 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -1284,6 +1284,22 @@ static int hns_nic_init_affinity_mask(int q_num, int ring_idx, return cpu; } +static void hns_nic_free_irq(int q_num, struct hns_nic_priv *priv) +{ + int i; + + for (i = 0; i < q_num * 2; i++) { + if (priv->ring_data[i].ring->irq_init_flag == RCB_IRQ_INITED) { + irq_set_affinity_hint(priv->ring_data[i].ring->irq, + NULL); + free_irq(priv->ring_data[i].ring->irq, + &priv->ring_data[i]); + priv->ring_data[i].ring->irq_init_flag = + RCB_IRQ_NOT_INITED; + } + } +} + static int hns_nic_init_irq(struct hns_nic_priv *priv) { struct hnae_handle *h = priv->ae_handle; @@ -1309,7 +1325,7 @@ static int hns_nic_init_irq(struct hns_nic_priv *priv) if (ret) { netdev_err(priv->netdev, "request irq(%d) fail\n", rd->ring->irq); - return ret; + goto out_free_irq; } disable_irq(rd->ring->irq); @@ -1324,6 +1340,10 @@ static int hns_nic_init_irq(struct hns_nic_priv *priv) } return 0; + +out_free_irq: + hns_nic_free_irq(h->q_num, priv); + return ret; } static int hns_nic_net_up(struct net_device *ndev) @@ -1371,6 +1391,7 @@ static int hns_nic_net_up(struct net_device *ndev) for (j = i - 1; j >= 0; j--) hns_nic_ring_close(ndev, j); + hns_nic_free_irq(h->q_num, priv); set_bit(NIC_STATE_DOWN, &priv->state); return ret; -- 1.9.1