Allow check_poison() to be called w/o cur_kthread
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 23 Sep 2015 20:04:30 +0000 (16:04 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 23 Sep 2015 20:46:28 +0000 (16:46 -0400)
If you called snprintf() or any other function that calls check_poison()
before smp init occurs, then we'd fail the assertion.  It's reasonable
to make those checks early on, so the assertion is now part of the 'if'.

kern/src/kthread.c

index 8dbc0b6..f6d2a36 100644 (file)
@@ -230,8 +230,8 @@ void check_poison(char *msg)
 {
 #ifdef CONFIG_KTHREAD_POISON
        struct per_cpu_info *pcpui = &per_cpu_info[core_id()];
-       assert(pcpui->cur_kthread && pcpui->cur_kthread->stacktop);
-       if (*kstack_bottom_addr(pcpui->cur_kthread->stacktop) != 0xdeadbeef) {
+       if (pcpui->cur_kthread && pcpui->cur_kthread->stacktop &&
+           (*kstack_bottom_addr(pcpui->cur_kthread->stacktop) != 0xdeadbeef)) {
                printk("\nBad kthread canary, msg: %s\n", msg);
                panic("");
        }