summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2013-05-10 18:33:55 +0000
committermikeb <mikeb@openbsd.org>2013-05-10 18:33:55 +0000
commitb6616845a05ac30797e9234c48a62b21b6793689 (patch)
tree38da22390f71292fc1222b4d1b435a10bfaf868e
parentditch unused zskbd_device_lookup; verified by sebastia@ (diff)
downloadwireguard-openbsd-b6616845a05ac30797e9234c48a62b21b6793689.tar.xz
wireguard-openbsd-b6616845a05ac30797e9234c48a62b21b6793689.zip
bail if device_lookup doesn't find anything; brings vscsi(4)
in line with other drivers. ok matthew
-rw-r--r--sys/dev/vscsi.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/sys/dev/vscsi.c b/sys/dev/vscsi.c
index 3da371c1636..98b0e319584 100644
--- a/sys/dev/vscsi.c
+++ b/sys/dev/vscsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vscsi.c,v 1.26 2011/07/17 22:46:48 matthew Exp $ */
+/* $OpenBSD: vscsi.c,v 1.27 2013/05/10 18:33:55 mikeb Exp $ */
/*
* Copyright (c) 2008 David Gwynne <dlg@openbsd.org>
@@ -296,6 +296,9 @@ vscsiioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
int read = 0;
int err = 0;
+ if (sc == NULL)
+ return (ENXIO);
+
rw_enter_write(&sc->sc_ioc_lock);
switch (cmd) {
@@ -476,6 +479,9 @@ vscsipoll(dev_t dev, int events, struct proc *p)
struct vscsi_softc *sc = DEV2SC(dev);
int revents = 0;
+ if (sc == NULL)
+ return (ENXIO);
+
if (events & (POLLIN | POLLRDNORM)) {
mtx_enter(&sc->sc_state_mtx);
if (!TAILQ_EMPTY(&sc->sc_ccb_i2t))
@@ -494,9 +500,14 @@ vscsipoll(dev_t dev, int events, struct proc *p)
int
vscsikqfilter(dev_t dev, struct knote *kn)
-{
+{
struct vscsi_softc *sc = DEV2SC(dev);
- struct klist *klist = &sc->sc_sel.si_note;
+ struct klist *klist;
+
+ if (sc == NULL)
+ return (ENXIO);
+
+ klist = &sc->sc_sel.si_note;
switch (kn->kn_filter) {
case EVFILT_READ:
@@ -548,6 +559,9 @@ vscsiclose(dev_t dev, int flags, int mode, struct proc *p)
struct vscsi_softc *sc = DEV2SC(dev);
struct vscsi_ccb *ccb;
+ if (sc == NULL)
+ return (ENXIO);
+
mtx_enter(&sc->sc_state_mtx);
KASSERT(sc->sc_state == VSCSI_S_RUNNING);
sc->sc_state = VSCSI_S_CONFIG;