From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0540F1C29 for ; Wed, 23 Nov 2022 09:33:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A9A9C433D6; Wed, 23 Nov 2022 09:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669195988; bh=dK9aI4+GTmYx8RbS7O1E/uW9R1LSW26QIfZslMRmk0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=amMyJLtW/nhDYPBwslYZ9iAFehut7hLNygHGuArCE36h7NCZ2OLrPBgA0hFcW1qqj QTdXVraDbK9hrKU1T74r4TX5QzJVTvPbLBhYUB2vkdGA84hzhnbodQiHIyXzy8ZsXX LPEjLW4CCg+kCYjxqKmWifyw6PeXIv3EA49nO60c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gaosheng Cui , Leon Romanovsky , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 088/181] bnxt_en: Remove debugfs when pci_register_driver failed Date: Wed, 23 Nov 2022 09:50:51 +0100 Message-Id: <20221123084606.137104415@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123084602.707860461@linuxfoundation.org> References: <20221123084602.707860461@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Gaosheng Cui [ Upstream commit 991aef4ee4f6eb999924f429b943441a32835c8f ] When pci_register_driver failed, we need to remove debugfs, which will caused a resource leak, fix it. Resource leak logs as follows: [ 52.184456] debugfs: Directory 'bnxt_en' with parent '/' already present! Fixes: cabfb09d87bd ("bnxt_en: add debugfs support for DIM") Signed-off-by: Gaosheng Cui Reviewed-by: Leon Romanovsky Reviewed-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index db1864a3f64a..117f5cc7c180 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -13697,8 +13697,16 @@ static struct pci_driver bnxt_pci_driver = { static int __init bnxt_init(void) { + int err; + bnxt_debug_init(); - return pci_register_driver(&bnxt_pci_driver); + err = pci_register_driver(&bnxt_pci_driver); + if (err) { + bnxt_debug_exit(); + return err; + } + + return 0; } static void __exit bnxt_exit(void) -- 2.35.1