mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org, Barret Rhoden <brho@google.com>,
	Ben Segall <bsegall@google.com>,
	David Vernet <void@manifault.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ingo Molnar <mingo@redhat.com>, Josh Don <joshdon@google.com>,
	Juri Lelli <juri.lelli@redhat.com>, Hao Luo <haoluo@google.com>,
	Mel Gorman <mgorman@suse.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>, Tejun Heo <tj@kernel.org>,
	Valentin Schneider <vschneid@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrea Righi <andrea.righi@canonical.com>
Subject: [PATCH] sched_ext: Call put_task_struct() only once in scx_ops_enable()
Date: Thu, 26 Sep 2024 15:30:12 +0200	[thread overview]
Message-ID: <6c4afcdc-fa86-4f0a-a6c1-ec8265190fd0@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Sep 2024 14:51:07 +0200

A put_task_struct() call was immediately used after a return value check
for a scx_ops_init_task() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/sched/ext.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 9ee5a9a261cc..4b89ea20e355 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -5091,8 +5091,8 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 		spin_unlock_irq(&scx_tasks_lock);

 		ret = scx_ops_init_task(p, task_group(p), false);
+		put_task_struct(p);
 		if (ret) {
-			put_task_struct(p);
 			spin_lock_irq(&scx_tasks_lock);
 			scx_task_iter_exit(&sti);
 			spin_unlock_irq(&scx_tasks_lock);
@@ -5101,7 +5101,6 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 			goto err_disable_unlock_all;
 		}

-		put_task_struct(p);
 		spin_lock_irq(&scx_tasks_lock);
 	}
 	scx_task_iter_exit(&sti);
--
2.46.1


             reply	other threads:[~2024-09-26 13:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-26 13:30 Markus Elfring [this message]
2024-09-27 20:11 ` Tejun Heo

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=6c4afcdc-fa86-4f0a-a6c1-ec8265190fd0@web.de \
    --to=markus.elfring@web.de \
    --cc=andrea.righi@canonical.com \
    --cc=brho@google.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=haoluo@google.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.com \
    /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®