summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2010-09-21 04:33:36 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2010-09-21 04:33:36 +0000
commit0b7a12d1509ce9298e24f128665fc89ae4bac37d (patch)
tree02438f0811580c087fb1acd6a6684ed77d5297dd
parent8cc2a607728079d5208102bbf0b8abd83c12915e (diff)
Add device_unref() calls as appropriate to vscsi(4) to fix reference
counting. Not really an issue, but dlg@ was teasing me about not finding any vscsi(4) bugs in a while. ;) "i trust you" dlg@ (without seeing the diff)
-rw-r--r--sys/dev/vscsi.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/dev/vscsi.c b/sys/dev/vscsi.c
index aac21711193..245b475bc3a 100644
--- a/sys/dev/vscsi.c
+++ b/sys/dev/vscsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vscsi.c,v 1.17 2010/07/24 20:15:31 matthew Exp $ */
+/* $OpenBSD: vscsi.c,v 1.18 2010/09/21 04:33:35 matthew Exp $ */
/*
* Copyright (c) 2008 David Gwynne <dlg@openbsd.org>
@@ -247,8 +247,10 @@ vscsiopen(dev_t dev, int flags, int mode, struct proc *p)
sc->sc_state = VSCSI_S_CONFIG;
mtx_leave(&sc->sc_state_mtx);
- if (rv != 0)
+ if (rv != 0) {
+ device_unref(&sc->sc_dev);
return (rv);
+ }
pool_init(&sc->sc_ccb_pool, sizeof(struct vscsi_ccb), 0, 0, 0,
"vscsiccb", NULL);
@@ -265,6 +267,7 @@ vscsiopen(dev_t dev, int flags, int mode, struct proc *p)
sc->sc_state = state;
mtx_leave(&sc->sc_state_mtx);
+ device_unref(&sc->sc_dev);
return (rv);
}
@@ -309,6 +312,7 @@ vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
rw_exit_write(&sc->sc_ioc_lock);
+ device_unref(&sc->sc_dev);
return (err);
}
@@ -464,6 +468,7 @@ vscsipoll(dev_t dev, int events, struct proc *p)
selrecord(p, &sc->sc_sel);
}
+ device_unref(&sc->sc_dev);
return (revents);
}
@@ -478,6 +483,7 @@ vscsikqfilter(dev_t dev, struct knote *kn)
kn->kn_fop = &vscsi_filtops;
break;
default:
+ device_unref(&sc->sc_dev);
return (1);
}
@@ -487,6 +493,7 @@ vscsikqfilter(dev_t dev, struct knote *kn)
SLIST_INSERT_HEAD(klist, kn, kn_selnext);
mtx_leave(&sc->sc_sel_mtx);
+ device_unref(&sc->sc_dev);
return (0);
}
@@ -555,6 +562,7 @@ vscsiclose(dev_t dev, int flags, int mode, struct proc *p)
sc->sc_state = VSCSI_S_CLOSED;
mtx_leave(&sc->sc_state_mtx);
+ device_unref(&sc->sc_dev);
return (0);
}