summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-07-18 10:58:42 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2009-07-18 10:58:42 +0000
commit904a36c91acddf7a4c92806b02217e4973c937b7 (patch)
tree1b020eacd12569cfdd2c716e692c7c177fa64b60
parenteca68a22f0f0ce4ebbb832f2ab012a1f924e3d1e (diff)
While detatching the device, workaround the case when a midi
entry is missing in cdevsw[], in which case vdevgone() is called with out of bounds argument. requested by dlg@
-rw-r--r--sys/dev/midi.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/dev/midi.c b/sys/dev/midi.c
index cabc4487fdc..02c0a99d9fc 100644
--- a/sys/dev/midi.c
+++ b/sys/dev/midi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midi.c,v 1.16 2006/12/21 02:28:47 krw Exp $ */
+/* $OpenBSD: midi.c,v 1.17 2009/07/18 10:58:41 ratchov Exp $ */
/*
* Copyright (c) 2003, 2004 Alexandre Ratchov
@@ -540,14 +540,13 @@ mididetach(struct device *self, int flags)
}
/* locate the major number */
- for (maj = 0; maj < nchrdev; maj++)
- if (cdevsw[maj].d_open == midiopen)
- break;
-
- /* Nuke the vnodes for any open instances (calls close). */
- mn = self->dv_unit;
- vdevgone(maj, mn, mn, VCHR);
-
+ for (maj = 0; maj < nchrdev; maj++) {
+ if (cdevsw[maj].d_open == midiopen) {
+ /* Nuke the vnodes for any open instances (calls close). */
+ mn = self->dv_unit;
+ vdevgone(maj, mn, mn, VCHR);
+ }
+ }
return 0;
}