diff options
author | anton <anton@openbsd.org> | 2020-09-26 12:01:57 +0000 |
---|---|---|
committer | anton <anton@openbsd.org> | 2020-09-26 12:01:57 +0000 |
commit | fdb37709a0132cd797ff5fa8f33155dd1a3eb5c4 (patch) | |
tree | 68490e7f43b02095b236752c69fc89719003fca6 /sys/dev/kcov.c | |
parent | KCOV_BUF_MAX_NMEMB is defined under _KERNEL in sys/kcov.h but only used (diff) | |
download | wireguard-openbsd-fdb37709a0132cd797ff5fa8f33155dd1a3eb5c4.tar.xz wireguard-openbsd-fdb37709a0132cd797ff5fa8f33155dd1a3eb5c4.zip |
Read curproc once in kcov_remote_enter() and kcov_remote_leave().
Diffstat (limited to 'sys/dev/kcov.c')
-rw-r--r-- | sys/dev/kcov.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/dev/kcov.c b/sys/dev/kcov.c index 3e15c86be87..e21a8c40254 100644 --- a/sys/dev/kcov.c +++ b/sys/dev/kcov.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kcov.c,v 1.31 2020/09/26 11:59:59 anton Exp $ */ +/* $OpenBSD: kcov.c,v 1.32 2020/09/26 12:01:57 anton Exp $ */ /* * Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org> @@ -559,6 +559,7 @@ kcov_remote_enter(int subsystem, void *id) { struct kcov_dev *kd; struct kcov_remote *kr; + struct proc *p; /* * We could end up here while executing a timeout triggered from a @@ -573,11 +574,12 @@ kcov_remote_enter(int subsystem, void *id) kr = kr_lookup(subsystem, id); if (kr == NULL || kr->kr_state != KCOV_STATE_READY) goto out; + p = curproc; kd = kr->kr_kd; if (kd != NULL && kd->kd_state == KCOV_STATE_TRACE) { kr->kr_nsections++; - KASSERT(curproc->p_kd == NULL); - curproc->p_kd = kd; + KASSERT(p->p_kd == NULL); + p->p_kd = kd; } out: mtx_leave(&kcov_mtx); @@ -587,19 +589,21 @@ void kcov_remote_leave(int subsystem, void *id) { struct kcov_remote *kr; + struct proc *p; /* See kcov_remote_enter(). */ if (inintr()) return; mtx_enter(&kcov_mtx); - if (curproc->p_kd == NULL) + p = curproc; + if (p->p_kd == NULL) goto out; kr = kr_lookup(subsystem, id); if (kr == NULL) goto out; - KASSERT(curproc->p_kd == kr->kr_kd); - curproc->p_kd = NULL; + KASSERT(p->p_kd == kr->kr_kd); + p->p_kd = NULL; if (--kr->kr_nsections == 0) wakeup(kr); out: |