Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp94290pxk; Wed, 16 Sep 2020 20:05:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0ZowAy5WnJSIXubziz/4Si4yHlthelG4+LQxg5iYhx0HjrQAE34aZTy8aDMBl1ZAAvav/ X-Received: by 2002:a17:906:5812:: with SMTP id m18mr29884203ejq.204.1600311955298; Wed, 16 Sep 2020 20:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600311955; cv=none; d=google.com; s=arc-20160816; b=kPC94HA7jItuk1PUjUb/lJtoANNompqOsfrT/beL3F3w5NakL1LbBESfy/6XxkC+0S DIbb1S6OhyXxjCOF11vmW9+9e7zpVWTcGu0mZutPdnjDVC/hGK7f+D4sP/yZS5Mhv/0d Q8ex6sDsDxkLO1K4blOEWhoPDxi6Eoe/VH0RdqpX3sCnlhhVxC2D0jev9axfQPsIBZec /D1GwJlOqSqfL9K2pEbJOps1wj7v2OSDwqeRDuAz1Cirtofimy0fMCr1NMezl2earvFU pf8ZAz9VPV1JZUCGNleSWTLY1tNwdi7h9g0HH7DecvQzYapz0TSWCXoAF9LFB/lBfrGj uTeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=f8TFKF3e6j1Oa9vSQp1tWPdzmPFH9TNtNTFFao5+GLo=; b=db48hVUNCdThKgyV+dLZWuO57wcBjFSMFUuJpdnz0sGL0B6uwTefKaFjiTl2LD/ppX 62HAskhjU+txnz2bjtnCH50as1bg/ibdH6QL9Vwhajbl8hF20Ei8UAhfeus2CtWETsLc d9U9sHTC0HAfrhERbJCUg1+5TptRKUBNLtlVpRPR+D7N1ixRfakslnIzkH+vDaMC7kl3 j4AYAEQR8fbfUjLzZ+499boKgKssL0s1iFsuMmWAyorhn/bYNa6/FI3mnVqPnWD4gWfJ TjmAZLQB4zXXP0ZC4e3OJFPo7xtKpHIp9YjoQ1T1Neli69BBVBSvnSPlU/w+XHMy0SCs Rhiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si13832645ejd.163.2020.09.16.20.05.32; Wed, 16 Sep 2020 20:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbgIQDEX (ORCPT + 99 others); Wed, 16 Sep 2020 23:04:23 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51718 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726007AbgIQDEW (ORCPT ); Wed, 16 Sep 2020 23:04:22 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6F50573C8FE365E61F5B; Thu, 17 Sep 2020 11:04:18 +0800 (CST) Received: from euler.huawei.com (10.175.124.27) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Thu, 17 Sep 2020 11:04:08 +0800 From: Wei Li To: Bin Luo , "David S. Miller" , Jakub Kicinski CC: , , , Subject: [PATCH] hinic: fix potential resource leak Date: Thu, 17 Sep 2020 11:03:07 +0800 Message-ID: <20200917030307.47195-1-liwei391@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In rx_request_irq(), it will just return what irq_set_affinity_hint() returns. If it is failed, the napi added is not deleted properly. Add a common exit for failures to do this. Signed-off-by: Wei Li --- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c index 5bee951fe9d4..63da9cc8ca51 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c @@ -543,18 +543,23 @@ static int rx_request_irq(struct hinic_rxq *rxq) if (err) { netif_err(nic_dev, drv, rxq->netdev, "Failed to set RX interrupt coalescing attribute\n"); - rx_del_napi(rxq); - return err; + goto err_irq; } err = request_irq(rq->irq, rx_irq, 0, rxq->irq_name, rxq); - if (err) { - rx_del_napi(rxq); - return err; - } + if (err) + goto err_irq; cpumask_set_cpu(qp->q_id % num_online_cpus(), &rq->affinity_mask); - return irq_set_affinity_hint(rq->irq, &rq->affinity_mask); + err = irq_set_affinity_hint(rq->irq, &rq->affinity_mask); + if (err) + goto err_irq; + + return 0; + +err_irq: + rx_del_napi(rxq); + return err; } static void rx_free_irq(struct hinic_rxq *rxq) -- 2.17.1