Module Name: src
Committed By: christos
Date: Fri Aug 17 16:21:20 UTC 2012
Modified Files:
src/sys/kern: tty.c
Log Message:
Better (not racy fix) from Paul Goyette.
To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/sys/kern/tty.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/tty.c
diff -u src/sys/kern/tty.c:1.252 src/sys/kern/tty.c:1.253
--- src/sys/kern/tty.c:1.252 Fri Aug 17 12:14:31 2012
+++ src/sys/kern/tty.c Fri Aug 17 12:21:19 2012
@@ -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 @@ tty_set_qsize(struct tty *tp, int newsiz
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;