mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Major Chen <major.chen@samsung.com>
Cc: "mingo@redhat.com" <mingo@redhat.com>,
	"juri.lelli@redhat.com" <juri.lelli@redhat.com>,
	"vincent.guittot@linaro.org" <vincent.guittot@linaro.org>,
	"dietmar.eggemann@arm.com" <dietmar.eggemann@arm.com>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"bsegall@google.com" <bsegall@google.com>,
	"mgorman@suse.de" <mgorman@suse.de>,
	"bristot@redhat.com" <bristot@redhat.com>,
	Hongfei Tang <hongfei.tang@samsung.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched,debug: fix dentry leak in update_sched_domain_debugfs
Date: Mon, 11 Jul 2022 10:04:01 +0200	[thread overview]
Message-ID: <YsvZcX4mZpP3a1L8@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20220711030341epcms5p173848e98b13c09eb2fcdf2fd7287526a@epcms5p1>

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

      reply	other threads:[~2022-07-11  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220711025311epcms5p874ccee18b6dd4e6a62759d0749936e61@epcms5p1>
2022-07-11  3:03 ` Major Chen
2022-07-11  8:04   ` Peter Zijlstra [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=YsvZcX4mZpP3a1L8@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hongfei.tang@samsung.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=major.chen@samsung.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®