From patchwork Sat Dec 10 17:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 32079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1434859wrr; Sat, 10 Dec 2022 09:53:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf7IEZSuI4cTrdEaxIyX1cpTLTi42cBkLE4d9w5Kiw8rVPlrepLN9KpiiBA8GR5g99Piqosz X-Received: by 2002:a50:fa88:0:b0:46c:d905:b9e8 with SMTP id w8-20020a50fa88000000b0046cd905b9e8mr9132711edr.23.1670694802760; Sat, 10 Dec 2022 09:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670694802; cv=none; d=google.com; s=arc-20160816; b=QRYHzZY7uV9SeiQuqk+4L5jv+/maqpLwNiawPB+f5/DLnYFpCS04uQ8IdHbaIGzrVi Twk3sB1r7dQDnVlutx3i+theud9lgGnO5A5Tam15368ZGDcK9+dHhIGfD8fME8kdAQS0 u45EpeAHonjoNjfhP023y8/8P1MHL+2UqReK0bPXLvMjp223tLbdkkcwEcHe+0y/Ts3d 3N0FLg2yZZctu3k2158mtR2/4jWqcF9lqa9pe1vQe5Z+9kMctzpIou/lZ/y9j0cKi7N8 1baLDddPTM2twFcUh9OE1otlNuOXG4hIKtmfavW7wYJL5aGX50tLbY5xoUZ4AXbH1zDl BXEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=TM3rWKtc2ol9TIFVt1QUYc6WjOgiufFxgR3hVsykK8U=; b=cJ+wN/4gMPF7sL2q0ChfBeoqGFNKkYKRQL4SxPXvOd/UsY5mMeY6TF5KYRIPtPeEmK 68FKBAwT6u8ayl3kbsc8J6qtvhkgLg38qbAhCjXJL0pWbkE8B/MfgrilTpiIuDjdDNbw P/DgKdsJ4aDKT0OJdnyyT98NPiPz97Jas5+SV7lxDEPvJvUbI6sI+oL84+oFlVllJVJo 1r8hw3payL+h4UhSUWJ4fKO913KhwiPfJinabD74ZQ3AVDOsGIsUqcOypARwB4YBVtOX FVwKwoaqSlDq38AOvVlN6dlnFqdbztlvWxk5VoIB+yYWe1SFs0PpEicv2a3b3obZmQJ8 EsJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w13-20020a056402268d00b0046b0cc42360si4395290edd.147.2022.12.10.09.52.44; Sat, 10 Dec 2022 09:53:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbiLJRfO (ORCPT + 99 others); Sat, 10 Dec 2022 12:35:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiLJRfM (ORCPT ); Sat, 10 Dec 2022 12:35:12 -0500 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9CDF18B37 for ; Sat, 10 Dec 2022 09:35:10 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 43kgp2tOxbw2u43kgpGtEJ; Sat, 10 Dec 2022 18:35:08 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Dec 2022 18:35:08 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vamsi Attunuru Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH] octeontx2-af: cn10k: mcs: Fix a resource leak in the probe and remove functions Date: Sat, 10 Dec 2022 18:35:00 +0100 Message-Id: <69f153db5152a141069f990206e7389f961d41ec.1670693669.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751850473650295750?= X-GMAIL-MSGID: =?utf-8?q?1751850473650295750?= In mcs_register_interrupts(), a call to request_irq() is not balanced by a corresponding free_irq(), neither in the error handling path, nor in the remove function. Add the missing calls. Fixes: 6c635f78c474 ("octeontx2-af: cn10k: mcs: Handle MCS block interrupts") Signed-off-by: Christophe JAILLET --- This patch is untested and speculative. I'm always reluctant to send patches around irq management, because it is sometimes tricky. Review with care! Maybe introducing a mcs_unregister_interrupts() function would be cleaner and more future proof. --- drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mcs.c b/drivers/net/ethernet/marvell/octeontx2/af/mcs.c index c0bedf402da9..f68a6a0e3aa4 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mcs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/mcs.c @@ -1184,10 +1184,13 @@ static int mcs_register_interrupts(struct mcs *mcs) mcs->tx_sa_active = alloc_mem(mcs, mcs->hw->sc_entries); if (!mcs->tx_sa_active) { ret = -ENOMEM; - goto exit; + goto free_irq; } return ret; + +free_irq: + free_irq(pci_irq_vector(mcs->pdev, MCS_INT_VEC_IP), mcs); exit: pci_free_irq_vectors(mcs->pdev); mcs->num_vec = 0; @@ -1589,6 +1592,7 @@ static void mcs_remove(struct pci_dev *pdev) /* Set MCS to external bypass */ mcs_set_external_bypass(mcs, true); + free_irq(pci_irq_vector(pdev, MCS_INT_VEC_IP), mcs); pci_free_irq_vectors(pdev); pci_release_regions(pdev); pci_disable_device(pdev);