Skip to contentSkip to conversation

sched: fix using uninilialzed rq in task_delta_exec()

PATCH In review Hiroshi Shimamoto 2 participants 3 messages Sep 29, 2008 – Sep 30, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: fix using uninilialzed rq in task_delta_exec()

From: Hiroshi Shimamoto <[email protected]>

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.

---
 kernel/sched.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
kernel/sched.c +2 -0
index 30b73fc..b6c0dd8 100644
@@ -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;
 }
Signature · 1 line
1.5.6
#1 lore raw
Quoted 10 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

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.

heh, just fixed that as well, latest tip/master should have the fix.

Have you seen any weirdness due to this uninitialized variable?

Ingo

#2 lore raw
Quoted 11 lines · Ingo Molnar
Quoted 9 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

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

Quoted 5 lines
Quoted 1 line

calling task_delta_exec() may cause unexpected pointer access.

heh, just fixed that as well, latest tip/master should have the fix.

Have you seen any weirdness due to this uninitialized variable?

No I've never seen any problem yesterday.
And I didn't have much time to use tip tree yesterday:)

Today's looks good.

thanks,
Hiroshi Shimamoto