Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Better (not racy fix) from Paul Goyette.



details:   https://anonhg.NetBSD.org/src/rev/b15f1da65294
branches:  trunk
changeset: 781078:b15f1da65294
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 17 16:21:19 2012 +0000

description:
Better (not racy fix) from Paul Goyette.

diffstat:

 sys/kern/tty.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r 83ab3ed08ada -r b15f1da65294 sys/kern/tty.c
--- a/sys/kern/tty.c    Fri Aug 17 16:14:31 2012 +0000
+++ b/sys/kern/tty.c    Fri Aug 17 16:21:19 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.252 2012/08/17 16:14:31 christos Exp $       */
+/*     $NetBSD: tty.c,v 1.253 2012/08/17 16:21:19 christos Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.252 2012/08/17 16:14:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.253 2012/08/17 16:21:19 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -230,15 +230,20 @@
        struct clist rawq, canq, outq;
        struct clist orawq, ocanq, ooutq;
 
-       if (tp->t_outq.c_cc != 0)
-               return EBUSY;
-
        clalloc(&rawq, newsize, 1);
        clalloc(&canq, newsize, 1);
        clalloc(&outq, newsize, 0);
 
        mutex_spin_enter(&tty_lock);
 
+       if (tp->t_outq.c_cc != 0) {
+               mutex_spin_exit(&tty_lock);
+               clfree(&rawq);
+               clfree(&canq);
+               clfree(&outq);
+               return EBUSY;
+       }
+
        orawq = tp->t_rawq;
        ocanq = tp->t_canq;
        ooutq = tp->t_outq;



Home | Main Index | Thread Index | Old Index