summaryrefslogtreecommitdiff
path: root/sys/kern/kern_synch.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-01-15 11:42:48 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-01-15 11:42:48 +0000
commit75187f8c4da7e97a5c8ce7af44012b9f34e410ec (patch)
tree720a0e73b573bb690c1a0cd5fa0da46d6a4a4fde /sys/kern/kern_synch.c
parent2a1fb76ac4cc1eb49faf6c7afa6b45a12d967700 (diff)
KASSERT on refcnt underflow.
ok mpi@ bluhm@
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r--sys/kern/kern_synch.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 0261a0309ce..874399d7024 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_synch.c,v 1.126 2015/11/23 10:56:20 mpi Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.127 2016/01/15 11:42:47 dlg Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
@@ -613,7 +613,12 @@ refcnt_take(struct refcnt *r)
int
refcnt_rele(struct refcnt *r)
{
- return (atomic_dec_int_nv(&r->refs) == 0);
+ u_int refcnt;
+
+ refcnt = atomic_dec_int_nv(&r->refs);
+ KASSERT(refcnt != ~0);
+
+ return (refcnt == 0);
}
void