aboutsummaryrefslogtreecommitdiff
path: root/kernel/sched/cpuacct.c
diff options
context:
space:
mode:
authorAnton Blanchard2016-04-06 21:59:50 +1000
committerIngo Molnar2016-04-13 13:22:37 +0200
commitbd92883051a0228cc34996b8e766111ba10c9aac (patch)
treef0f1e3253cd3938d48bbbbd5f6605c02e0237043 /kernel/sched/cpuacct.c
parent2c923e94cd9c6acff3b22f0ae29cfe65e2658b40 (diff)
sched/cpuacct: Check for NULL when using task_pt_regs()
task_pt_regs() can return NULL for kernel threads, so add a check. This fixes an oops at boot on ppc64. Reported-and-Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Tested-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Anton Blanchard <anton@samba.org> Acked-by: Zhao Lei <zhaolei@cn.fujitsu.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: efault@gmx.de Cc: htejun@gmail.com Cc: linuxppc-dev@lists.ozlabs.org Cc: tj@kernel.org Cc: yangds.fnst@cn.fujitsu.com Link: http://lkml.kernel.org/r/20160406215950.04bc3f0b@kryten Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/cpuacct.c')
-rw-r--r--kernel/sched/cpuacct.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index df947e07aac1..41f85c4d0938 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -316,12 +316,11 @@ static struct cftype files[] = {
void cpuacct_charge(struct task_struct *tsk, u64 cputime)
{
struct cpuacct *ca;
- int index;
+ int index = CPUACCT_USAGE_SYSTEM;
+ struct pt_regs *regs = task_pt_regs(tsk);
- if (user_mode(task_pt_regs(tsk)))
+ if (regs && user_mode(regs))
index = CPUACCT_USAGE_USER;
- else
- index = CPUACCT_USAGE_SYSTEM;
rcu_read_lock();