Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6928238rwn; Tue, 13 Sep 2022 11:00:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR6cahEH+v3CUVuAzItZnvU3JZjd4OgzG0uQOG9U+kCVpnGwB/Qwee9uYPO9VOxyG+H+ApqJ X-Received: by 2002:a17:902:d489:b0:178:1ad6:6603 with SMTP id c9-20020a170902d48900b001781ad66603mr17960275plg.158.1663092027878; Tue, 13 Sep 2022 11:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663092027; cv=none; d=google.com; s=arc-20160816; b=H4iP0esB7Z0KXEnN30q2mnPEra11lAtFKGPzHMmjo6ipgShEPgQ8ccQuIo/3e+nfZp 7YuBtt7OweGkTSSgOObFRGFQ4VAMpi9NU/1x/TqKYzcmlnvZqmyV+zG827I5jp1AjWRh h+3TfELY8GZbq+G4WO7T3yB7AkBc4zcFAGwSg5mlIvWEUqRlb7ypLmFqAkEV9OrE9kK2 V0l6G57ajElIwfehzNk5cPgf8gJfpgjFMTK5azFDDlU4Vzhc9QlYu8elseHCEPVPHzQe sX8rhn9h1+Zf06dCR9r+Lf2uHGokLacxbEPE6cfljdIsQXjbjs01y2Aog27pHzBHRmfT dHug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=NYivW7kGXMdzt9vJTehSUvSt+4w7RPSokt3xYSE0iuE=; b=V6zz2Ep+5ZLqoq3Jrf1UoDMSs4P44kCpBUv2hY+f5Arz6hIuHYoTza7H6XbH7kS3TU +uQDWLx3FKfo0L+uXBkoWrnRqF0tVoFVpgK+mWHU7WAFw0KBbLm299e3XejOZpsS5TEe WI/Yt23LkGFZtSaoiYZCLrByUuiY0WtFgppLDGNgVXRXZfTC5hBnnpi0QldTHrwDuOFZ 8FnOxpQJ4GxhwM8By+jZ7ao0JI9pvD7pdJwNR3FUy9WXqTxRwKHDl+liJI1IQ8KtayYG wMgxRq2O5brLute5K7w2xqZ5JxJyp4nQCD7R88ACsCJorbjQ3MeuV8ZTZLLYRpG7LHEA zuXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=mNLXbpbG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a656a81000000b00434bfa4c2d7si13680823pgu.317.2022.09.13.11.00.14; Tue, 13 Sep 2022 11:00:27 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=mNLXbpbG; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232383AbiIMRu6 (ORCPT + 99 others); Tue, 13 Sep 2022 13:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233588AbiIMRu1 (ORCPT ); Tue, 13 Sep 2022 13:50:27 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D73583BEA; Tue, 13 Sep 2022 09:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NYivW7kGXMdzt9vJTehSUvSt+4w7RPSokt3xYSE0iuE=; b=mNLXbpbGexsGm7Dl3VPIIsQLR9 st3jg0j5fPR1VAeY+tHcbUE/gIALlzHoryZPRpi6q8xtCrkz3PxJMB4Z5QSaVsppUiJKPKV+2PYHR +BRZZutQnZd3T4wWxDrr2hN4jAjDgOewapVfbkFIdGZZfJXc8bWn2aAsWS2QwIrDS33hGZYXeKP4F 82VBugtGPqAOqPwk/PiCjsMkMPkQ9+adpF6Hw3b+3kbppxAUQBVZwMARpeZL5Agud/X5NVF05mbY3 Es7KG5sfg3k8T5pQ1AuMqtFxpAty+WU4r9CXPK9+SUfHlxfjrlWSzzTcwFeYYXPRPGFx9a8xhD0y+ yxZ9MM4A==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:34296) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oY95n-0003IX-FU; Tue, 13 Sep 2022 17:48:59 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oY95m-0000pK-3i; Tue, 13 Sep 2022 17:48:58 +0100 Date: Tue, 13 Sep 2022 17:48:58 +0100 From: "Russell King (Oracle)" To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Marcin Wojtas , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, stable Subject: Re: [PATCH 5.19 005/192] net: mvpp2: debugfs: fix memory leak when using debugfs_lookup() Message-ID: References: <20220913140410.043243217@linuxfoundation.org> <20220913140410.277221532@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220913140410.277221532@linuxfoundation.org> Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, 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 On Tue, Sep 13, 2022 at 04:01:51PM +0200, Greg Kroah-Hartman wrote: > 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); This looks broken to me. What happens if this is built as a module, and the module is loaded, binds (and creates the directory), then is removed, and then re- inserted? Nothing removes the old directory, so doesn't debugfs_create_dir() fail, resulting in subsequent failure to add any subsequent debugfs entries? I don't think this patch should be backported to stable trees until this point is addressed. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!