Skip to content

Commit

Permalink
PM: domains: fix memory leak with using debugfs_lookup()
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Greg Kroah-Hartman authored and Rafael J. Wysocki committed Feb 9, 2023
1 parent 4ec5183 commit 0b6200e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0b6200e

Please sign in to comment.