drivers: base: power: fix memory leak with using debugfs_lookup()
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 1/1 drivers: base: power: fix memory leak with using debugfs_lookup()
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.
--- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/base/power/domain.c +1 -4
@@ -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)
Signature · 1 line
2.39.1
Rafael J. Wysocki
maintainerQuoted 29 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at
once.Cc "Rafael J. Wysocki" <[email protected]>Cc Kevin Hilman <[email protected]>Cc Ulf Hansson <[email protected]>Cc Pavel Machek <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/base/power/domain.c +0
-2@@ -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; -
drivers/base/power/domain.c static void genpd_debug_add(struct generic_pm_domain *genpd);
Quoted 10 lines
drivers/base/power/domain.c +1
-3if (!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?
Greg Kroah-Hartman
maintainerQuoted 39 lines · Rafael J. Wysocki
Quoted 37 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at
once.Cc "Rafael J. Wysocki" <[email protected]>Cc Kevin Hilman <[email protected]>Cc Ulf Hansson <[email protected]>Cc Pavel Machek <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/base/power/domain.c +1
-4@@ -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); }
Quoted 4 lines
drivers/base/power/domain.c static void genpd_debug_add(struct generic_pm_domain *genpd);
Quoted 2 lines
drivers/base/power/domain.c +0
-1static 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
Rafael J. Wysocki
maintainerQuoted 41 lines · Greg Kroah-Hartman
Quoted 39 lines · Rafael J. Wysocki
Quoted 37 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at
once.Cc "Rafael J. Wysocki" <[email protected]>Cc Kevin Hilman <[email protected]>Cc Ulf Hansson <[email protected]>Cc Pavel Machek <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/base/power/domain.c +1
-4@@ -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); }
Quoted 7 lines
Quoted 4 lines
drivers/base/power/domain.c static void genpd_debug_add(struct generic_pm_domain *genpd);
Quoted 2 lines
drivers/base/power/domain.c +0
-1static 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!
Quoted 7 lines · Greg Kroah-Hartman
When calling
debugfs_lookup()the result must havedput()called on it, otherwise the memory will leak over time. To make things simpler, just calldebugfs_lookup_and_remove()instead which handles all of the logic at
once.
Quoted 8 lines
Cc "Rafael J. Wysocki" <[email protected]>Cc Kevin Hilman <[email protected]>Cc Ulf Hansson <[email protected]>Cc Pavel Machek <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Kind regards
Uffe
Quoted 26 lines
--- drivers/base/power/domain.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/base/power/domain.c +1
-5@@ -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