Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6745868rwn; Tue, 13 Sep 2022 08:29:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7R0LFzVrVFxCvjbulRAWxCMZwz8dNwiM/DJZQCTyyYGZCJ7S3iVcP8O+wCz/fft96XEhx+ X-Received: by 2002:a05:6402:298e:b0:451:129e:1b35 with SMTP id eq14-20020a056402298e00b00451129e1b35mr17172492edb.79.1663082947646; Tue, 13 Sep 2022 08:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663082947; cv=none; d=google.com; s=arc-20160816; b=YEd3hdryOkb1vqEBTtUepDHqmWPI/46czwq/y36laljYfAQ7VoxoeeYAxvpTDcO1DS YKhBT4OgmLWFerlkNb5TC2eQRbC7zbNx+F++VgrdBI8NCR7k3U+zPEgHCIlRJc4HC2UB mAHUJr0xVjmY3iw0710Bt1AIYiPrmMKVJfXCi/Wn7PLWnncbn6LkbV/5pLW939ufKChy d1f9Fw8QJ2EK/lVUYzlaCUxcbz1XLxv5A781aIEdh/MPekCC/h6Eq65kTcfXt3mKAjp+ Gul34vceCdU/1G0CZRoJIF/5/vMw1aF1xbJ6nYa7mKwi6xqkowTzOLJY3i+tHR/3HfYH kWDw== 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=JviWsf+yY16dPQK9PIDGro/FYbLx8B0CnHkbDEFL6v087piBzElxrPhl/mEg21gxLO Z/tgDq622taA/MKm0N6QHx6N49yfom1VI3kDyhcsDtgmzDJ+u0lPwn7LgzvUGWKpA38b bdE/WNTP1FLg1gTYOZdtGWOyDnkeWoku8bdQmH4oLy5vZ3NuSm914BGI4OcipBx0vGQd sOj3axjYAAMuTO1qHdSpUBQ0wXeS2LVh3joLrO0+0P6mPGiFEf5npVshrbFLOy6Qg7Uj YBYFcbd/2JdFaIaL1wTxaQ5FRMEdP5IYQlSWFtpQpczyBWkgv7cfgCJ3e+VKo+AffPJY c2uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EW+AQM07; 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 p4-20020a170906604400b007309350f2f9si8886245ejj.555.2022.09.13.08.28.41; Tue, 13 Sep 2022 08:29:07 -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=EW+AQM07; 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 S232525AbiIMOJj (ORCPT + 99 others); Tue, 13 Sep 2022 10:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232519AbiIMOIt (ORCPT ); Tue, 13 Sep 2022 10:08:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C27219001; Tue, 13 Sep 2022 07:08:30 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A1F9A614AA; Tue, 13 Sep 2022 14:08:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9500EC433D6; Tue, 13 Sep 2022 14:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078108; bh=wgRZma+e4X5kCGxfMKh1BxeU5ur5lm00SFY+zuuMEMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EW+AQM07IF1ZDkQq5W8bZzq4MbxVWntch72bW/wIDRwoViLKy4VGKkigbWfWVv7du KoaMCYligCwkgwGdTF+8AWmKTu/trbxu7iwbREIOEdiAtHb6ijUhd1yWM5giZMg4mE Y7rDjo/8JJgePWVgQIq5i+vy62iogs8fXMhdTcyo= 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.19 005/192] net: mvpp2: debugfs: fix memory leak when using debugfs_lookup() Date: Tue, 13 Sep 2022 16:01:51 +0200 Message-Id: <20220913140410.277221532@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140410.043243217@linuxfoundation.org> References: <20220913140410.043243217@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);