summaryrefslogtreecommitdiff
path: root/sys/kern/subr_autoconf.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-02-09 12:37:19 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-02-09 12:37:19 +0000
commitbd35c1918ff930eced7fabbfb0c0f60dff887f47 (patch)
tree40fb39d639cb8117bb910ee1f2f30d430926a37f /sys/kern/subr_autoconf.c
parentc9e9bef7d02e102033f5e1ae8a8a805df2732a7c (diff)
use atomic ops to increment and decrement the device ref count in
device_ref and device_unref. ok guenther@ deraadt@
Diffstat (limited to 'sys/kern/subr_autoconf.c')
-rw-r--r--sys/kern/subr_autoconf.c7
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);
}