Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6821056rwn; Tue, 13 Sep 2022 09:24:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR46mmkHWk+ZzXXaNrfeDxY2E8vELxUgBksqF8p6kZBLO22ZBJYZ77VmYGRHVpLA7umxattU X-Received: by 2002:a63:b59:0:b0:434:2374:6d12 with SMTP id a25-20020a630b59000000b0043423746d12mr28592601pgl.311.1663086282481; Tue, 13 Sep 2022 09:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086282; cv=none; d=google.com; s=arc-20160816; b=F2vkBs0jyndT+y1yfdGei3T3aJQ2LWQS0geVOtk2ov+3YN2jE1HrVEMtZUfzsYG4Jd TNmmbWqZP+4Eqjb4UMsukdjVNiP4aTOdZttcnYWJetjaTd5eohr/s40IFv5vHuQiUQ3v 19Z+1R9VT0h+DntCFpArag8f6U3sfaIxl8iPegOTK8Nhdcf+K7Py7BIBMzXYPmV9bWHF ftB+Yjw58l0NueJ9S7IsTgTTUl6DzRvAq07eTogiAU9TPaJFnDjSxQqMavcjl73bZ/C4 unlo0+QytrZshRLfbf3Jy0CGfeh5IzeMLkQiVC22JMtte21rlrhOukRl1spOhiW1XpCe 5++g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W9BEOQlvPIYJmlAxWFQ/3jgfwmefTdgGEejQutZs6q8=; b=qCgl4alfm+QVbruN1DeBspudLuSWMIhsieaXbPXWMFksImnTawPX738uZBJunjDJ1N VXkJO63M/n+FxQQoFmB/SKPbE6JB5QZxUJat0BJ11BFrxckZSI7bUDQmsSaR20DD//yB +KM8fUlWAuEzyrKb8Nhis457gISN7uyNFqugS8jV7R1pFNe1CpHkvn74xoJalZ9raRwR dDRNMcc2vq9TqTMX9gzaafrmEKywbZ7lgqPmCVDJ20rEI0JarKACBDw+hhPH0HHXpRJH 7/1n5MaCujF1cwq0hINF+zzK8iQexR4e3TAtfbrE9DzdvFrH8ZZBrLCO+OSXhvc80D8/ TnBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=izy8OIRx; 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 h21-20020a056a001a5500b0054289be8a17si9184132pfv.328.2022.09.13.09.24.24; Tue, 13 Sep 2022 09:24:42 -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=izy8OIRx; 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 S232422AbiIMO1R (ORCPT + 99 others); Tue, 13 Sep 2022 10:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233588AbiIMO0n (ORCPT ); Tue, 13 Sep 2022 10:26:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C2C5D110; Tue, 13 Sep 2022 07:16:47 -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 14EEDB80F4B; Tue, 13 Sep 2022 14:16:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D233C433D6; Tue, 13 Sep 2022 14:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078605; bh=wgRZma+e4X5kCGxfMKh1BxeU5ur5lm00SFY+zuuMEMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=izy8OIRx+TI9ke3U2TtO03aLiVAg9ptMAlSlleKZTlJDJWvLsqmjCAK5hUttOZRck JiK4JJieerqw72iG3jvEmt+pT5DjQ7xE1ewXE/4ZEyO2owGhOnyTyLnQuMqvyw2k43 xcupUdzmzTQVjA9J+QfaKFzyO1nkreVvqapy4dlw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcin Wojtas , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, stable Subject: [PATCH 5.15 005/121] net: mvpp2: debugfs: fix memory leak when using debugfs_lookup() Date: Tue, 13 Sep 2022 16:03:16 +0200 Message-Id: <20220913140357.557975060@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140357.323297659@linuxfoundation.org> References: <20220913140357.323297659@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 From: Greg Kroah-Hartman commit fe2c9c61f668cde28dac2b188028c5299cedcc1e upstream. 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: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- 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 *p 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);