All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: rafael@kernel.org, Kevin Hilman <khilman@kernel.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 15:45:28 +0100	[thread overview]
Message-ID: <CAPDyKFq_yAJOSZO7WsPZKV_aGcFAs0kWqpNN-_=ywa8n=8D=-g@mail.gmail.com> (raw)
In-Reply-To: <20230202141545.2295679-1-gregkh@linuxfoundation.org>

On Thu, 2 Feb 2023 at 15:15, 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>

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  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)
> --
> 2.39.1
>

      parent reply	other threads:[~2023-02-02 14:46 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
2023-02-09 19:34     ` Rafael J. Wysocki
2023-02-02 14:45 ` Ulf Hansson [this message]

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='CAPDyKFq_yAJOSZO7WsPZKV_aGcFAs0kWqpNN-_=ywa8n=8D=-g@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.