Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp505021rwn; Thu, 15 Sep 2022 02:02:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6F4q7tnvtbk96rQHVnDJJLyW9MzzDjlIM4hTj7rxTs5zKD1M2nW23n8IwWjmae0/ykIS5d X-Received: by 2002:a17:90b:4a4f:b0:202:5bbb:b76f with SMTP id lb15-20020a17090b4a4f00b002025bbbb76fmr9692657pjb.230.1663232551311; Thu, 15 Sep 2022 02:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663232551; cv=none; d=google.com; s=arc-20160816; b=TFCDTDRKuQgkp4iOTghglgxqzE4CoSh/6SwMBN2ehi4ND1QU+nVOv5Ub8By6oNWK2k OCTN2Lu8j181mrD4bKyPWVAjXKbvJkb1vDexsyrqwp37MpjIE1En4j1g6qPnmA8k9xBM 2UKWJR7f8RmuRZU4YD0SlYyAn8SCBKHT8NAJJ53xSSzxrfWtcJOIoX9JdIZScaG8Iu0m iX4ARIyUE1QiNbgmXUTllDNKREVhcnqQ+8JKalBkVkcl6nj0Oth4em/4WWe0rmnCQOcn 8wUR2OMvBsV+GucMdnJwQ6bwRxP7hZFIJ93GOTaHOgfd1Q9iN6QNmBeq9QR6sJvf9x7O dCRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EWgdeD0N0PW7CLBmH7SSCJWW0ytfG2lrXrgRro7WI3Y=; b=0HWpHdMw8U5Rdw/TdXcDDKnm+mdB68+e9lLaw5oLA6Osj+2WOeKGxUU1w3iQL0fqxE oAw9X5kk5v7gz+5dUn6WmnJDcvA9SZMHO6CgBslpHrYZa3AVSwendsG0fxuT6xBtTiss iE6nMuyF1WGekCDBG3Vu09Bn/e+PCnzhwCg9wgUNreXur57/24gt61ZCUFcjt5whv97G jjgpnhstVlQId0CpJbwf8ED7QxEsuHyioUHr+pDAGWcMxxGgtj9TgPot7KtoetMFMj43 j5h36B3uXVwgavQAz2dhEvg9npGgGORg7RC6oCOk8S4aak10tio2cW0ZQKiYr8Wz3SGL D2yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qgxd2rrP; 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 j3-20020a17090a588300b00203336ddd4asi1277128pji.56.2022.09.15.02.02.18; Thu, 15 Sep 2022 02:02:31 -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=qgxd2rrP; 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 S230154AbiIOIfs (ORCPT + 99 others); Thu, 15 Sep 2022 04:35:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbiIOIf3 (ORCPT ); Thu, 15 Sep 2022 04:35:29 -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 8A5A62B24F; Thu, 15 Sep 2022 01:35:28 -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 47558B81E64; Thu, 15 Sep 2022 08:35:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7890AC433C1; Thu, 15 Sep 2022 08:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663230926; bh=Ot/IEjx60+Ugq7shRIji6JO7/KL6tCs4ZKC7guXQRt0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qgxd2rrPMa9Ixwb8B6TmfT6+a8bvfq7DXh2qh2q0nOdD5SiAZE7WxVmRz8lt/mhdE wnK8C2jYiwfyWYgT+VQdbXA/ag/lVLk3/hIrUzBS+nHEhERppM0/O4fbyCjEn6kwKd QBWNBrdYv1VCO3gISmHYLFwVlfwLxfZU/FoNW3Lk= Date: Thu, 15 Sep 2022 10:35:51 +0200 From: Greg Kroah-Hartman To: "Russell King (Oracle)" 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: 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 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 05:48:58PM +0100, Russell King (Oracle) wrote: > 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. I'll drop this for now and get back to the fixup next week. thanks, greg k-h