diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2016-02-01 23:34:32 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2016-02-01 23:34:32 +0000 |
commit | 617716095cf6313a3380448b32b86beede5d5006 (patch) | |
tree | e76a2488671ece5c907b9b7d402a73d3e9688098 /sys/kern/kern_synch.c | |
parent | 28432aafa2b26b7203a8a32d9abe209e218b17a1 (diff) |
add a DIAGNOSTIC for refcnt_take overflow.
ok mpi@
Diffstat (limited to 'sys/kern/kern_synch.c')
-rw-r--r-- | sys/kern/kern_synch.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 874399d7024..da949842d4b 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.127 2016/01/15 11:42:47 dlg Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.128 2016/02/01 23:34:31 dlg Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -607,7 +607,14 @@ refcnt_init(struct refcnt *r) void refcnt_take(struct refcnt *r) { +#ifdef DIAGNOSTIC + u_int refcnt; + + refcnt = atomic_inc_int_nv(&r->refs); + KASSERT(refcnt != 0); +#else atomic_inc_int(&r->refs); +#endif } int |