diff options
author | 2015-02-09 12:37:18 +0000 | |
---|---|---|
committer | 2015-02-09 12:37:18 +0000 | |
commit | ffc7124743bffd9ab9889f29d608f4a16d9244fb (patch) | |
tree | 8bbcce4029080489bee8a5e00f2b461fd7b1823d | |
parent | Add SOCK_CLOEXEC | SOCK_NONBLOCK to two more socket calls. (diff) | |
download | wireguard-openbsd-ffc7124743bffd9ab9889f29d608f4a16d9244fb.tar.xz wireguard-openbsd-ffc7124743bffd9ab9889f29d608f4a16d9244fb.zip |
use atomic ops to increment and decrement the device ref count in
device_ref and device_unref.
ok guenther@ deraadt@
-rw-r--r-- | sys/kern/subr_autoconf.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 49838565ae5..04378697eaa 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.84 2015/01/22 01:19:51 dlg Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.85 2015/02/09 12:37:18 dlg Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -922,7 +922,7 @@ device_mpath(void) void device_ref(struct device *dv) { - dv->dv_ref++; + atomic_inc_int(&dv->dv_ref); } /* @@ -937,8 +937,7 @@ device_unref(struct device *dv) { struct cfattach *ca; - dv->dv_ref--; - if (dv->dv_ref == 0) { + if (atomic_dec_int_nv(&dv->dv_ref) == 0) { ca = dv->dv_cfdata->cf_attach; free(dv, M_DEVBUF, ca->ca_devsize); } |