summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-11-29 17:15:45 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-11-29 17:15:45 +0000
commite37ec72c97cfecbf21df2b4348147efc8b6b1fb3 (patch)
treef87a3629051549476904a85a7e44f790c178aba4 /sys/dev
parentcc9be5fca1566592445732942100c33791656bc1 (diff)
the code for managing tty vs cua usage collision was free'ing all sorts
of critical structures when it hit a collision. Also, ttyopen is ldisc 0, so it should not be called twice (and furthermore, with the wrong dev_t) original report from mikeb, ok dlg mikeb and discussed with miod
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/ucom.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c
index aea1a43fdf4..e246023a1cd 100644
--- a/sys/dev/usb/ucom.c
+++ b/sys/dev/usb/ucom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ucom.c,v 1.54 2011/07/03 19:38:50 deraadt Exp $ */
+/* $OpenBSD: ucom.c,v 1.55 2011/11/29 17:15:44 deraadt Exp $ */
/* $NetBSD: ucom.c,v 1.49 2003/01/01 00:10:25 thorpej Exp $ */
/*
@@ -453,25 +453,24 @@ ucomopen(dev_t dev, int flag, int mode, struct proc *p)
SET(tp->t_state, TS_CARR_ON);
else
CLR(tp->t_state, TS_CARR_ON);
- } else if (ISSET(tp->t_state, TS_XCLUDE) && suser(p, 0) != 0) {
- error = EBUSY;
- goto bad;
- } else
+ } else if (ISSET(tp->t_state, TS_XCLUDE) && suser(p, 0) != 0)
+ return (EBUSY);
+ else
s = spltty();
if (UCOMCUA(dev)) {
if (ISSET(tp->t_state, TS_ISOPEN)) {
/* Someone is already dialed in */
- error = EBUSY;
- goto bad1;
+ splx(s);
+ return (EBUSY);
}
sc->sc_cua = 1;
} else {
/* tty (not cua) device, wait for carrier */
if (ISSET(flag, O_NONBLOCK)) {
if (sc->sc_cua) {
- error = EBUSY;
- goto bad1;
+ splx(s);
+ return (EBUSY);
}
} else {
while (sc->sc_cua || (!ISSET(tp->t_cflag, CLOCAL) &&
@@ -487,17 +486,14 @@ ucomopen(dev_t dev, int flag, int mode, struct proc *p)
*/
if (error && ISSET(tp->t_state, TS_WOPEN)) {
CLR(tp->t_state, TS_WOPEN);
- goto bad1;
+ splx(s);
+ goto bad;
}
}
}
}
splx(s);
- error = ttyopen(UCOMUNIT(dev), tp, p);
- if (error)
- goto bad;
-
error = (*LINESW(tp, l_open))(dev, tp, p);
if (error)
goto bad;
@@ -522,8 +518,6 @@ fail_0:
ucom_unlock(sc);
return (error);
-bad1:
- splx(s);
bad:
ucom_lock(sc);
ucom_cleanup(sc);