From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Kevin Hilman <khilman@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>, Pavel Machek <pavel@ucw.cz>,
Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: base: power: fix memory leak with using debugfs_lookup()
Date: Thu, 2 Feb 2023 16:09:54 +0100 [thread overview]
Message-ID: <Y9vSQhnCdnInKu/b@kroah.com> (raw)
In-Reply-To: <CAJZ5v0gMpORi=kB4-PFswmhY2HJggJO+Qh2SMjCuHyn3z+zmTw@mail.gmail.com>
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
> <gregkh@linuxfoundation.org> 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" <rafael@kernel.org>
> > Cc: Kevin Hilman <khilman@kernel.org>
> > Cc: Ulf Hansson <ulf.hansson@linaro.org>
> > Cc: Pavel Machek <pavel@ucw.cz>
> > Cc: Len Brown <len.brown@intel.com>
> > Cc: linux-pm@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > 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.
thanks!
greg k-h
next prev parent reply other threads:[~2023-02-02 15:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 14:15 [PATCH] drivers: base: power: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-02 14:23 ` Rafael J. Wysocki
2023-02-02 15:09 ` Greg Kroah-Hartman [this message]
2023-02-09 19:34 ` Rafael J. Wysocki
2023-02-02 14:45 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9vSQhnCdnInKu/b@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=khilman@kernel.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox