]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix schedstats null deref in sched_exec
authorNathan Lynch <nathanl@austin.ibm.com>
Tue, 14 Sep 2004 00:40:03 +0000 (17:40 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 14 Sep 2004 00:40:03 +0000 (17:40 -0700)
In sched_exec, schedstat_inc will dereference a null pointer if no domain
is found with the SD_BALANCE_EXEC flag set.  This was exposed during
testing of the previous patches where cpus are temporarily attached to a
dummy domain without SD_BALANCE_EXEC set.

Signed-off-by: Nathan Lynch <nathanl@austin.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/sched.c

index 3de761b2b262542d32cbe659b10511bf1272110f..3af37db1e2e49dee22d2d78e1dac63311ae759c3 100644 (file)
@@ -1727,8 +1727,8 @@ void sched_exec(void)
                if (tmp->flags & SD_BALANCE_EXEC)
                        sd = tmp;
 
-       schedstat_inc(sd, sbe_attempts);
        if (sd) {
+               schedstat_inc(sd, sbe_attempts);
                new_cpu = find_idlest_cpu(current, this_cpu, sd);
                if (new_cpu != this_cpu) {
                        schedstat_inc(sd, sbe_pushed);