Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Provide consistent locking around getc() in ttread(...
details: https://anonhg.NetBSD.org/src/rev/b8031a5f6b79
branches: trunk
changeset: 781781:b8031a5f6b79
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Sep 30 11:49:44 2012 +0000
description:
Provide consistent locking around getc() in ttread(). This is necessary
to prevent crashes in MPSAFE tty drivers like ucom.
diffstat:
sys/kern/tty.c | 13 +++++--------
1 files changed, 5 insertions(+), 8 deletions(-)
diffs (58 lines):
diff -r cd5bec781682 -r b8031a5f6b79 sys/kern/tty.c
--- a/sys/kern/tty.c Sun Sep 30 11:29:42 2012 +0000
+++ b/sys/kern/tty.c Sun Sep 30 11:49:44 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.253 2012/08/17 16:21:19 christos Exp $ */
+/* $NetBSD: tty.c,v 1.254 2012/09/30 11:49:44 mlelstv Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.253 2012/08/17 16:21:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.254 2012/09/30 11:49:44 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1928,7 +1928,6 @@
goto loop;
}
read:
- mutex_spin_exit(&tty_lock);
/*
* Input present, check for input mapping and processing.
@@ -1940,16 +1939,14 @@
*/
if (CCEQ(cc[VDSUSP], c) &&
ISSET(lflag, IEXTEN|ISIG) == (IEXTEN|ISIG)) {
- mutex_spin_enter(&tty_lock);
ttysig(tp, TTYSIG_PG1, SIGTSTP);
if (first) {
error = ttypause(tp, hz);
- mutex_spin_exit(&tty_lock);
if (error)
break;
+ mutex_spin_exit(&tty_lock);
goto loop;
- } else
- mutex_spin_exit(&tty_lock);
+ }
break;
}
/*
@@ -1973,11 +1970,11 @@
break;
first = 0;
}
+
/*
* Look to unblock output now that (presumably)
* the input queue has gone down.
*/
- mutex_spin_enter(&tty_lock);
if (ISSET(tp->t_state, TS_TBLOCK) && tp->t_rawq.c_cc < TTYHOG / 5) {
if (ISSET(tp->t_iflag, IXOFF) &&
cc[VSTART] != _POSIX_VDISABLE &&
Home |
Main Index |
Thread Index |
Old Index