summaryrefslogtreecommitdiffstats
path: root/sys/dev/midi.c
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2009-07-18 10:58:41 +0000
committerratchov <ratchov@openbsd.org>2009-07-18 10:58:41 +0000
commitd3538cb0d835190ce97e12faaaf0538315543d04 (patch)
treed7b438016e26df1af23a39451474b5725519046b /sys/dev/midi.c
parent#include stdio.h for printf here also. (diff)
downloadwireguard-openbsd-d3538cb0d835190ce97e12faaaf0538315543d04.tar.xz
wireguard-openbsd-d3538cb0d835190ce97e12faaaf0538315543d04.zip
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@
Diffstat (limited to 'sys/dev/midi.c')
-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;
}