Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp396297pxk; Thu, 17 Sep 2020 06:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP0ZC5eySzNVt0W9689grXpbBsnQio3OKmyBPYo2D3gRNmvEBkkxJUMe83XOW/YYfVpl2U X-Received: by 2002:aa7:d296:: with SMTP id w22mr33136704edq.327.1600348196994; Thu, 17 Sep 2020 06:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600348196; cv=none; d=google.com; s=arc-20160816; b=DNuDT1ikTqKiHFW+jNLN1T0dzLMwenckPxkf6s3H7t9LvPZpe46vu9I5W9MWUdbD7i +8n/FHblNwmcXFUSnvZqPwuTwiUulZ1w1UahMlaZL0FxgXEaFtd1PL8IqF5X1uggwd95 sf2EmnRK7YHYvbdx9XsMLvizvh926O9uOFqjJg6GdSHptPaWkBXFc0owNIHITTEfPd7c 28wlT3bLP+GJYaGXU3Ba8gPAqXXmP5aWKwSBr/henwryYZXeLBYXuzCh786X2Sip17ls iS6qVULDCmDuaIsbAZj1tz6lYS6vBkbZEaMKd7PxV6DE/TYA02yqjVFmSv8J+pF2ha0n Enww== 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=TsTj5galhw/tXm+0/ahsFkn11VYstteDO+R+rDTnDlc=; b=JBoQh4O3bPuNzqsiw+nM+7xrUl+urlTPH4VMWd9rX79XGc+MLlXF4BSVVAGLAHmVZP /DzndZrJ0sWRgN/E6TcHjbZxZoj498MmPpYTWDaQBBmrzyNW5FvOMyUDYIwtCrTx/o8d GME9+NwXQtbvRinY5Nw1VmSPCC58cFgj5T64VAcldOQzoVaC1oHzj6W4TgN0sV0d8tGf 9SwZJ4Jv53EkQQgzIdlG/sdG0Cr/ZnGVjB2nZdZpBexDYovQaXxp9CAmUCWIcHjB3LJ0 pTmmApiB8gn2QeZ2aTLRi3vrh8lP0p/NDRKp7AeyvHdLrDyrH3OpWUgzM60STAwOo4+7 z9gg== 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 zh8si9305204ejb.92.2020.09.17.06.09.28; Thu, 17 Sep 2020 06:09:56 -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 S1726897AbgIQMb7 (ORCPT + 99 others); Thu, 17 Sep 2020 08:31:59 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:41022 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726683AbgIQMbg (ORCPT ); Thu, 17 Sep 2020 08:31:36 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 61DAD6FD8536E7EA2B93; Thu, 17 Sep 2020 20:30:41 +0800 (CST) Received: from euler.huawei.com (10.175.124.27) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Thu, 17 Sep 2020 20:30:29 +0800 From: Wei Li To: Bin Luo , "David S. Miller" , Jakub Kicinski CC: , , , Subject: [PATCH net v2] hinic: fix potential resource leak Date: Thu, 17 Sep 2020 20:29:50 +0800 Message-ID: <20200917122950.36878-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 and irq requested are not freed properly. So add exits for failures to handle these. Signed-off-by: Wei Li --- v1 -> v2: - Free irq as well when irq_set_affinity_hint() fails. --- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 21 +++++++++++++------- 1 file changed, 14 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..cc1d425d070c 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c @@ -543,18 +543,25 @@ 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_req_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_req_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_affinity; + + return 0; + +err_irq_affinity: + free_irq(rq->irq, rxq); +err_req_irq: + rx_del_napi(rxq); + return err; } static void rx_free_irq(struct hinic_rxq *rxq) -- 2.17.1