lkml.org 
[lkml]   [2022]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sched,debug: fix dentry leak in update_sched_domain_debugfs
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).

\
 
 \ /
  Last update: 2022-07-11 10:05    [W:0.068 / U:22.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site