void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
 {
        const struct exception_table_entry *entry;
-       unsigned long *stackend;
 
        /* Are we prepared to handle this fault?  */
        if ((entry = search_exception_tables(regs->nip)) != NULL) {
        printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n",
                regs->nip);
 
-       stackend = end_of_stack(current);
-       if (*stackend != STACK_END_MAGIC)
+       if (task_stack_end_corrupted(current))
                printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");
 
        die("Kernel access of bad area", regs, sig);
 
           unsigned long address, int signal, int si_code)
 {
        struct task_struct *tsk = current;
-       unsigned long *stackend;
        unsigned long flags;
        int sig;
 
 
        show_fault_oops(regs, error_code, address);
 
-       stackend = end_of_stack(tsk);
-       if (*stackend != STACK_END_MAGIC)
+       if (task_stack_end_corrupted(tsk))
                printk(KERN_EMERG "Thread overran stack, or stack corrupted\n");
 
        tsk->thread.cr2         = address;
 
 }
 
 #endif
+#define task_stack_end_corrupted(task) \
+               (*(end_of_stack(task)) != STACK_END_MAGIC)
 
 static inline int object_is_on_stack(void *obj)
 {
 
                        i++;
        }
 
-       if (*end_of_stack(current) != STACK_END_MAGIC) {
+       if (task_stack_end_corrupted(current)) {
                print_max_stack();
                BUG();
        }