From nobody Thu May 7 21:41:16 2026 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 1C7D5C433EF for ; Tue, 17 May 2022 21:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353132AbiEQVAH (ORCPT ); Tue, 17 May 2022 17:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346684AbiEQU74 (ORCPT ); Tue, 17 May 2022 16:59:56 -0400 Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D4A0532CB for ; Tue, 17 May 2022 13:59:55 -0700 (PDT) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id r4IJn7nvuVfTCr4IKncUEs; Tue, 17 May 2022 22:59:54 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 17 May 2022 22:59:54 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: vburru@marvell.com, aayarekar@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, sburla@marvell.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 1/2] octeon_ep: Fix a memory leak in the error handling path of octep_request_irqs() Date: Tue, 17 May 2022 22:59:51 +0200 Message-Id: <38fb0e6de389eeb06820aba8b0a15c5534d8f540.1652819974.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" '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 Acked-by: Veerasenareddy Burru Reviewed-by: Dan Carpenter --- v2: Add Acked-by tag v1: https://lore.kernel.org/all/78dcfbb5d22328bc83edbfc74af10c3625c54087.16= 52629833.git.christophe.jaillet@wanadoo.fr/ --- 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 =3D NULL; alloc_err: return -1; } --=20 2.34.1 From nobody Thu May 7 21:41:16 2026 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 D3D14C433EF for ; Tue, 17 May 2022 21:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353154AbiEQVAN (ORCPT ); Tue, 17 May 2022 17:00:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353128AbiEQVAG (ORCPT ); Tue, 17 May 2022 17:00:06 -0400 Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15DF7532DE for ; Tue, 17 May 2022 14:00:04 -0700 (PDT) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id r4ISnP1h2JXxRr4ISnYTVj; Tue, 17 May 2022 23:00:03 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 17 May 2022 23:00:03 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: vburru@marvell.com, aayarekar@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, sburla@marvell.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 2/2] octeon_ep: Fix irq releasing in the error handling path of octep_request_irqs() Date: Tue, 17 May 2022 22:59:59 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When taken, the error handling path does not undo correctly what has already been allocated. Introduce a new loop index, 'j', in order to simplify the error handling path and rewrite part of it. It is now written with the same logic and intermediate variables used when resources are allocated. This is much more straightforward. Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support= ") Signed-off-by: Christophe JAILLET Reviewed-by: Dan Carpenter --- v2: Introduce 'j' and use it in the 2nd for loop Rewrite the error handling path (Dan Carpenter) v1: https://lore.kernel.org/all/a1b6f082fff4e68007914577961113bc452c8030.16= 52629833.git.christophe.jaillet@wanadoo.fr/ --- .../ethernet/marvell/octeon_ep/octep_main.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/= net/ethernet/marvell/octeon_ep/octep_main.c index 6b60a03574a0..a9b82d221780 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -202,7 +202,7 @@ static int octep_request_irqs(struct octep_device *oct) struct msix_entry *msix_entry; char **non_ioq_msix_names; int num_non_ioq_msix; - int ret, i; + int ret, i, j; =20 num_non_ioq_msix =3D CFG_GET_NON_IOQ_MSIX(oct->conf); non_ioq_msix_names =3D CFG_GET_NON_IOQ_MSIX_NAMES(oct->conf); @@ -233,23 +233,23 @@ static int octep_request_irqs(struct octep_device *oc= t) } =20 /* Request IRQs for Tx/Rx queues */ - for (i =3D 0; i < oct->num_oqs; i++) { - ioq_vector =3D oct->ioq_vector[i]; - msix_entry =3D &oct->msix_entries[i + num_non_ioq_msix]; + for (j =3D 0; j < oct->num_oqs; j++) { + ioq_vector =3D oct->ioq_vector[j]; + msix_entry =3D &oct->msix_entries[j + num_non_ioq_msix]; =20 snprintf(ioq_vector->name, sizeof(ioq_vector->name), - "%s-q%d", netdev->name, i); + "%s-q%d", netdev->name, j); ret =3D request_irq(msix_entry->vector, octep_ioq_intr_handler, 0, ioq_vector->name, ioq_vector); if (ret) { netdev_err(netdev, "request_irq failed for Q-%d; err=3D%d", - i, ret); + j, ret); goto ioq_irq_err; } =20 - cpumask_set_cpu(i % num_online_cpus(), + cpumask_set_cpu(j % num_online_cpus(), &ioq_vector->affinity_mask); irq_set_affinity_hint(msix_entry->vector, &ioq_vector->affinity_mask); @@ -257,10 +257,13 @@ static int octep_request_irqs(struct octep_device *oc= t) =20 return 0; ioq_irq_err: - 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]); + while (j) { + --j; + ioq_vector =3D oct->ioq_vector[j]; + msix_entry =3D &oct->msix_entries[j + num_non_ioq_msix]; + + irq_set_affinity_hint(msix_entry->vector, NULL); + free_irq(msix_entry->vector, ioq_vector); } non_ioq_irq_err: while (i) { --=20 2.34.1