From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5B24C636D3 for ; Thu, 9 Feb 2023 19:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjBITet (ORCPT ); Thu, 9 Feb 2023 14:34:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjBITep (ORCPT ); Thu, 9 Feb 2023 14:34:45 -0500 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D65A410259; Thu, 9 Feb 2023 11:34:44 -0800 (PST) Received: by mail-ej1-f45.google.com with SMTP id lu11so9650660ejb.3; Thu, 09 Feb 2023 11:34:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FQyPKHsnpkMtHTu8wIUgMn7V8u4D4+AVOfDvP1szK50=; b=zr5hyeBKdUpmenmZsXcn9FmLkaOIms+DVYEr63SGk1Nbwb8ZSkrqq3J9rNmSaX7hyJ pAR581h2YRNVG6AA93UdFH2Gkr+SRQI//VXEzfsH8hhohRwVP+7Q5BFEJcyUCKUxZtT1 tGyghz6S2QD/9iALq9+pUZBhZMTtcpXgUuOZz2zME8q4bx4oFdv9Y/0/tbo3ktpCfwU4 SYbMOC1xS33vFmz5zS4qbWcSSmZfRpF9YZWQjxPY8AHNrXwaEa1vzg+wwb8c8ULyjEkp lRKdXJDjsGKlkMIBPuKGSKCjdib/VPQhnG3WT9rTD+TatYsx4sf+kgCDO9Vjhv5zCd0m PSaQ== X-Gm-Message-State: AO0yUKV7rIdmVdL+jnY5iAwCH+kHU/A73OreTXztVR0f83td2in6qNd/ 9iacKCFkK/jQzmcX/ISWo7799bVr3njBAoj4al0= X-Google-Smtp-Source: AK7set+wluxzNyhZvd4jbRFYLJUQ9ghyXw8Cm0oCBDn53ajufkx4Ht18b90WGecWYVh9M9ucqrzSMPx7hO/eypNm2XA= X-Received: by 2002:a17:906:ce2e:b0:87f:575a:9b67 with SMTP id sd14-20020a170906ce2e00b0087f575a9b67mr2944602ejb.274.1675971283500; Thu, 09 Feb 2023 11:34:43 -0800 (PST) MIME-Version: 1.0 References: <20230202141545.2295679-1-gregkh@linuxfoundation.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 9 Feb 2023 20:34:32 +0100 Message-ID: Subject: Re: [PATCH] drivers: base: power: fix memory leak with using debugfs_lookup() To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Pavel Machek , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 2, 2023 at 4:09 PM Greg Kroah-Hartman wrote: > > On Thu, Feb 02, 2023 at 03:23:46PM +0100, Rafael J. Wysocki wrote: > > On Thu, Feb 2, 2023 at 3:15 PM Greg Kroah-Hartman > > wrote: > > > > > > When calling debugfs_lookup() the result must have dput() called on it, > > > otherwise the memory will leak over time. To make things simpler, just > > > call debugfs_lookup_and_remove() instead which handles all of the logic > > > at > > > once. > > > > > > Cc: "Rafael J. Wysocki" > > > Cc: Kevin Hilman > > > Cc: Ulf Hansson > > > Cc: Pavel Machek > > > Cc: Len Brown > > > Cc: linux-pm@vger.kernel.org > > > Cc: linux-kernel@vger.kernel.org > > > Signed-off-by: Greg Kroah-Hartman > > > --- > > > drivers/base/power/domain.c | 5 +---- > > > 1 file changed, 1 insertion(+), 4 deletions(-) > > > > > > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c > > > index 967bcf9d415e..6097644ebdc5 100644 > > > --- a/drivers/base/power/domain.c > > > +++ b/drivers/base/power/domain.c > > > @@ -220,13 +220,10 @@ static void genpd_debug_add(struct generic_pm_domain *genpd); > > > > > > static void genpd_debug_remove(struct generic_pm_domain *genpd) > > > { > > > - struct dentry *d; > > > - > > > if (!genpd_debugfs_dir) > > > return; > > > > > > - d = debugfs_lookup(genpd->name, genpd_debugfs_dir); > > > - debugfs_remove(d); > > > + debugfs_lookup_and_remove(genpd->name, genpd_debugfs_dir); > > > } > > > > > > static void genpd_update_accounting(struct generic_pm_domain *genpd) > > > -- > > > > Does this depend on anything in your tree, or can I apply it? > > It does not depend on anything in any of my trees, it's made against > Linus's tree right now so please take it through yours. Applied for 6.3 now, thanks!