public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH -tip] sched: fix using uninilialzed rq in task_delta_exec()
Date: Mon, 29 Sep 2008 11:23:09 -0700	[thread overview]
Message-ID: <48E11D0D.3040000@ct.jp.nec.com> (raw)

From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

compiler warnings;

  CC      kernel/sched.o
kernel/sched.c: In function 'task_delta_exec':
kernel/sched.c:4055: warning: unused variable 'flags'
kernel/sched.c:4054: warning: 'rq' is used uninitialized in this function

calling task_delta_exec() may cause unexpected pointer access.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
 kernel/sched.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 30b73fc..b6c0dd8 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4055,6 +4055,7 @@ unsigned long long task_delta_exec(struct task_struct *p)
 	unsigned long flags;
 	u64 ns = 0;
 
+	rq = task_rq_lock(p, &flags);
 	if (task_current(rq, p)) {
 		u64 delta_exec;
 
@@ -4063,6 +4064,7 @@ unsigned long long task_delta_exec(struct task_struct *p)
 		if ((s64)delta_exec > 0)
 			ns = delta_exec;
 	}
+	task_rq_unlock(rq, &flags);
 
 	return ns;
 }
-- 
1.5.6


             reply	other threads:[~2008-09-29 18:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-29 18:23 Hiroshi Shimamoto [this message]
2008-09-30  8:58 ` [PATCH -tip] sched: fix using uninilialzed rq in task_delta_exec() Ingo Molnar
2008-09-30 16:45   ` Hiroshi Shimamoto

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=48E11D0D.3040000@ct.jp.nec.com \
    --to=h-shimamoto@ct.jp.nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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