All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched,debug: fix dentry leak in update_sched_domain_debugfs
       [not found] <CGME20220711025311epcms5p874ccee18b6dd4e6a62759d0749936e61@epcms5p1>
@ 2022-07-11  3:03 ` Major Chen
  2022-07-11  8:04   ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Major Chen @ 2022-07-11  3:03 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot
  Cc: Hongfei Tang, linux-kernel

 
update_sched_domain_debugfs() uses debugfs_lookup() to find wanted dentry(which has
been created by debugfs_create_dir() before), but not call dput() to return this dentry
back. This result in dentry leak even debugfs_remove() is called.
 
Signed-off-by: major.chen <major.chen@samsung.com>
---
 kernel/sched/debug.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
 
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index bb3d63b..4ffea2d 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -412,11 +412,14 @@ void update_sched_domain_debugfs(void)
 
         for_each_cpu(cpu, sd_sysctl_cpus) {
                 struct sched_domain *sd;
-                struct dentry *d_cpu;
+                struct dentry *d_cpu, *d_lookup;
                 char buf[32];
 
                 snprintf(buf, sizeof(buf), "cpu%d", cpu);
-                debugfs_remove(debugfs_lookup(buf, sd_dentry));
+                d_lookup = debugfs_lookup(buf, sd_dentry);
+                debugfs_remove(d_lookup);
+                if (!IS_ERR_OR_NULL(d_lookup))
+                        dput(d_lookup);
                 d_cpu = debugfs_create_dir(buf, sd_dentry);
 
                 i = 0;
-- 
2.7.4
 
 



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sched,debug: fix dentry leak in update_sched_domain_debugfs
  2022-07-11  3:03 ` [PATCH] sched,debug: fix dentry leak in update_sched_domain_debugfs Major Chen
@ 2022-07-11  8:04   ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2022-07-11  8:04 UTC (permalink / raw)
  To: Major Chen
  Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, bristot, Hongfei Tang, linux-kernel

On Mon, Jul 11, 2022 at 11:03:41AM +0800, Major Chen wrote:
>  
> update_sched_domain_debugfs() uses debugfs_lookup() to find wanted dentry(which has
> been created by debugfs_create_dir() before), but not call dput() to return this dentry
> back. This result in dentry leak even debugfs_remove() is called.
>  
> Signed-off-by: major.chen <major.chen@samsung.com>
> ---
>  kernel/sched/debug.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>  
> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> index bb3d63b..4ffea2d 100644
> --- a/kernel/sched/debug.c
> +++ b/kernel/sched/debug.c
> @@ -412,11 +412,14 @@ void update_sched_domain_debugfs(void)
>  
>          for_each_cpu(cpu, sd_sysctl_cpus) {
>                  struct sched_domain *sd;
> -                struct dentry *d_cpu;
> +                struct dentry *d_cpu, *d_lookup;
>                  char buf[32];
>  
>                  snprintf(buf, sizeof(buf), "cpu%d", cpu);
> -                debugfs_remove(debugfs_lookup(buf, sd_dentry));
> +                d_lookup = debugfs_lookup(buf, sd_dentry);
> +                debugfs_remove(d_lookup);
> +                if (!IS_ERR_OR_NULL(d_lookup))
> +                        dput(d_lookup);
>                  d_cpu = debugfs_create_dir(buf, sd_dentry);
>  
>                  i = 0;

Please try again, while not HTML, this email is severely whitespace
mangled (there's no '\t' characters in it for one).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-11  8:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20220711025311epcms5p874ccee18b6dd4e6a62759d0749936e61@epcms5p1>
2022-07-11  3:03 ` [PATCH] sched,debug: fix dentry leak in update_sched_domain_debugfs Major Chen
2022-07-11  8:04   ` Peter Zijlstra

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.