From patchwork Sun May 15 15:56:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12850050 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45211C433FE for ; Sun, 15 May 2022 15:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237642AbiEOP5V (ORCPT ); Sun, 15 May 2022 11:57:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbiEOP5S (ORCPT ); Sun, 15 May 2022 11:57:18 -0400 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9995813F8C for ; Sun, 15 May 2022 08:57:16 -0700 (PDT) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id qGcCn0Tbaqn1xqGcCnISX0; Sun, 15 May 2022 17:57:15 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 15 May 2022 17:57:15 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: Veerasenareddy Burru , Abhijit Ayarekar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Satananda Burla Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 1/2] octeon_ep: Fix a memory leak in the error handling path of octep_request_irqs() Date: Sun, 15 May 2022 17:56:44 +0200 Message-Id: <78dcfbb5d22328bc83edbfc74af10c3625c54087.1652629833.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 'oct->non_ioq_irq_names' is not freed in the error handling path of octep_request_irqs(). Add the missing kfree(). Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support") Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index e020c81f3455..6b60a03574a0 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -267,6 +267,8 @@ static int octep_request_irqs(struct octep_device *oct) --i; free_irq(oct->msix_entries[i].vector, oct); } + kfree(oct->non_ioq_irq_names); + oct->non_ioq_irq_names = NULL; alloc_err: return -1; } From patchwork Sun May 15 15:56:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12850051 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E6D0C433F5 for ; Sun, 15 May 2022 15:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237517AbiEOP7F (ORCPT ); Sun, 15 May 2022 11:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235104AbiEOP7D (ORCPT ); Sun, 15 May 2022 11:59:03 -0400 Received: from smtp.smtpout.orange.fr (smtp07.smtpout.orange.fr [80.12.242.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D9B1409C for ; Sun, 15 May 2022 08:59:01 -0700 (PDT) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id qGcCn0Tbaqn1xqGe3nISmG; Sun, 15 May 2022 17:59:00 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 15 May 2022 17:59:00 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: Veerasenareddy Burru , Abhijit Ayarekar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Satananda Burla Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH 2/2] octeon_ep: Fix irq releasing in the error handling path of octep_request_irqs() Date: Sun, 15 May 2022 17:56:45 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org For the error handling to work as expected, the index in the 'oct->msix_entries' array must be tweaked because, when the irq are requested there is: msix_entry = &oct->msix_entries[i + num_non_ioq_msix]; So in the error handling path, 'i + num_non_ioq_msix' should be used instead of 'i'. The 2nd argument of free_irq() also needs to be adjusted. Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support") Signed-off-by: Christophe JAILLET --- I think that the wording above is awful, but I'm sure you get it. Feel free to rephrase everything to have it more readable. --- drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 6b60a03574a0..4dcae805422b 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -257,10 +257,12 @@ static int octep_request_irqs(struct octep_device *oct) return 0; ioq_irq_err: + i += num_non_ioq_msix; while (i > num_non_ioq_msix) { --i; irq_set_affinity_hint(oct->msix_entries[i].vector, NULL); - free_irq(oct->msix_entries[i].vector, oct->ioq_vector[i]); + free_irq(oct->msix_entries[i].vector, + oct->ioq_vector[i - num_non_ioq_msix]); } non_ioq_irq_err: while (i) {