Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2028879rwe; Fri, 2 Sep 2022 07:33:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wFs7zu7K1QqBcPv5XceBdnIgWa+QvRJcw87Idp5Cbwzj6CrYcrtNuPtdRKy8ISmXyfDP1 X-Received: by 2002:a17:902:d2c4:b0:175:4064:ac72 with SMTP id n4-20020a170902d2c400b001754064ac72mr13899414plc.142.1662129223288; Fri, 02 Sep 2022 07:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129223; cv=none; d=google.com; s=arc-20160816; b=Qqev2vuogwMrP/KGfJY3QCAmKzCaZ0lDY+VMAdhg6o+9dwNiepG8m+xNyNH1hPRtJE tpqBI52b5x2peDz6cSLJnNg3FWQSwoQmDKhEb0TdQPfpR3k3hAL6GyYKCZ6dC8LhyXZf mgSLlr0UPFi4jImYdl2DXHBSTVHcwuvkvxD6eKtAIEsJo1Tur/M4FJk+PLM+JPpnV38d /zYjfaX1YxfFKNnnpNrUkanW+81preRfq6MPtJuxAi31Jped4/TZdFW0OOrmsseaVvNB l52cfWXkAbnJWWgRIO7PDcHGjq1d66r6fGrdJaBIpnA3PhMLk7CGkHvVwnckf0mWlPJM GNrA== 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:dkim-signature; bh=NOJZTtayY9cLV7nryFmTCmqWJo7Zfd8DCRjTTZFAnPY=; b=vTcJD0zx4htfP5feXTPmW1ElzyyIYAPFE9LKtYSs0F5NBNvPknKeifY0E8p7QDdvWz 6Syx3NWzzu2IC0oJcJt1457Juzhz47COJ3hlMTJ3MLCpRS9eDKQGT7T9ewLuoBrW9hCz EqN1UoTAVtDKMVQBl0HAQd/Hikq05NYgRmF26vYRIclfHxrru10e25TxwIwqZkeIunqW EqdY2E78gpt0PBOJlQSS0ZU+MyhmumG1Nz4rhEQYV6hQV5HnQpz+4ILduTquiAUU8ZFw MDZxedn9TYnsHL7FFBVwIg47QpHcXf3qzqUvZubDnH0yFYBg/E3kBw83uueiZ9HRGpmO MRnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eLVzjJON; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a17090a0d0800b001f505550ef9si2208048pja.113.2022.09.02.07.33.29; Fri, 02 Sep 2022 07:33:43 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eLVzjJON; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238241AbiIBOVD (ORCPT + 99 others); Fri, 2 Sep 2022 10:21:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236221AbiIBOUq (ORCPT ); Fri, 2 Sep 2022 10:20:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C5A5F5492; Fri, 2 Sep 2022 06:46:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3BFFCB82932; Fri, 2 Sep 2022 13:41:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 493B8C433D7; Fri, 2 Sep 2022 13:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662126077; bh=mMsRtna7E2z9yafUmLhJ8p87GPEczi5fo98BTKfwIco=; h=From:To:Cc:Subject:Date:From; b=eLVzjJONXoo8OGfXvkJO/fJjsYzzdITadgxk8ikrhygJH9eKtYJEI+/MsTcCQWDip haeSkZgAQ23q1vlNRBH3sKO42ogw3EOpeQ+xsDBdFWomx+DGGtB394XZPX68InjmhV SVOKCWRaFxne7aZS2tXbZrgqBJB0obRmSqRB7G1U= From: Greg Kroah-Hartman To: mw@semihalf.com, linux@armlinux.org.uk Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, stable Subject: [PATCH net] net: mvpp2: debugfs: fix memory leak when using debugfs_lookup() Date: Fri, 2 Sep 2022 15:41:11 +0200 Message-Id: <20220902134111.280657-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1587; i=gregkh@linuxfoundation.org; h=from:subject; bh=mMsRtna7E2z9yafUmLhJ8p87GPEczi5fo98BTKfwIco=; b=owGbwMvMwCRo6H6F97bub03G02pJDMlC7N+1l744lmtYcNF3dt+enDnioWdZXk+e/qah/BNngY1c rubHjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIbSaG+Vmftpw5W8G02yRh3RL2D4 Xs/yetrGSYp8bLes56zqsNN2dn8Vwuz+oOEDaSAAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up to be much simpler logic and only create the root debugfs directory once when the driver is first accessed. That resolves the memory leak and makes things more obvious as to what the intent is. Cc: Marcin Wojtas Cc: Russell King Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Cc: stable Fixes: 21da57a23125 ("net: mvpp2: add a debugfs interface for the Header Parser") Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c index 4a3baa7e0142..0eec05d905eb 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c @@ -700,10 +700,10 @@ void mvpp2_dbgfs_cleanup(struct mvpp2 *priv) void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name) { - struct dentry *mvpp2_dir, *mvpp2_root; + static struct dentry *mvpp2_root; + struct dentry *mvpp2_dir; int ret, i; - mvpp2_root = debugfs_lookup(MVPP2_DRIVER_NAME, NULL); if (!mvpp2_root) mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL); -- 2.37.3