Don't forget to relock the TTY after uiomove() returns an error.

Peter Holm just discovered this funny bug inside the TTY code: if
uiomove() in ttydisc_write() returns an error, we forget to relock the
TTY before jumping out of ttydisc_write(). Fix it by placing
tty_unlock() and tty_lock() around uiomove().

Submitted by:	pho
This commit is contained in:
Ed Schouten 2008-11-12 09:04:44 +00:00
parent d1340303b9
commit 87fe0fa84f

View file

@ -460,17 +460,15 @@ ttydisc_write(struct tty *tp, struct uio *uio, int ioflag)
MPASS(oblen == 0);
/* Step 1: read data. */
tty_unlock(tp);
obstart = ob;
nlen = MIN(uio->uio_resid, sizeof ob);
tty_unlock(tp);
error = uiomove(ob, nlen, uio);
tty_lock(tp);
if (error != 0)
break;
oblen = nlen;
tty_lock(tp);
if (tty_gone(tp)) {
error = ENXIO;
break;