summaryrefslogtreecommitdiff
path: root/sys/arch/sh
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-10-23 19:56:54 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-10-23 19:56:54 +0000
commit935479d01a84f4989bc84dfe189509ab1c305d02 (patch)
tree8363439d210fa22fc3f289a947cc52d44102143b /sys/arch/sh
parent3f4c54dd327079884f8be5e26eb40f42842b2a6c (diff)
Do not panic on a ddb invocation with curproc == NULL, and don't try to
userret() either on return.
Diffstat (limited to 'sys/arch/sh')
-rw-r--r--sys/arch/sh/sh/trap.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/arch/sh/sh/trap.c b/sys/arch/sh/sh/trap.c
index 2c4032cb55c..2c60d3adb1c 100644
--- a/sys/arch/sh/sh/trap.c
+++ b/sys/arch/sh/sh/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.2 2006/10/17 03:33:39 drahn Exp $ */
+/* $OpenBSD: trap.c,v 1.3 2006/10/23 19:56:53 miod Exp $ */
/* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */
/* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */
@@ -150,10 +150,9 @@ general_exception(struct proc *p, struct trapframe *tf, uint32_t va)
uvmexp.traps++;
- if (p == NULL)
- goto do_panic;
-
if (usermode) {
+ if (p == NULL)
+ goto do_panic;
KDASSERT(p->p_md.md_regs == tf); /* check exception depth */
expevt |= EXP_USER;
}
@@ -164,9 +163,9 @@ general_exception(struct proc *p, struct trapframe *tf, uint32_t va)
tra = _reg_read_4(SH_(TRA));
if (tra == (_SH_TRA_BREAK << 2)) {
kdb_trap(expevt, tra, tf);
- goto out;
} else
goto do_panic;
+ break;
case EXPEVT_TRAPA | EXP_USER:
/* Check for debugger break */
tra = _reg_read_4(SH_(TRA));
@@ -190,8 +189,8 @@ general_exception(struct proc *p, struct trapframe *tf, uint32_t va)
case EXPEVT_ADDR_ERR_LD: /* FALLTHROUGH */
case EXPEVT_ADDR_ERR_ST:
- KDASSERT(p->p_md.md_pcb->pcb_onfault != NULL);
- if (p->p_md.md_pcb->pcb_onfault == 0)
+ KDASSERT(p && p->p_md.md_pcb->pcb_onfault != NULL);
+ if (p == NULL || p->p_md.md_pcb->pcb_onfault == 0)
goto do_panic;
tf->tf_spc = (int)p->p_md.md_pcb->pcb_onfault;
break;