From 87fe0fa84f764c307c8a999f7a44262403b16d36 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Wed, 12 Nov 2008 09:04:44 +0000 Subject: [PATCH] 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 --- sys/kern/tty_ttydisc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/kern/tty_ttydisc.c b/sys/kern/tty_ttydisc.c index 0d7dd7f33d9..800ad136c6f 100644 --- a/sys/kern/tty_ttydisc.c +++ b/sys/kern/tty_ttydisc.c @@ -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;