Module Name: src
Committed By: martin
Date: Sat Apr 9 06:34:06 UTC 2011
Modified Files:
src/sys/kern: tty.c tty_pty.c
Log Message:
In ttymalloc() explicitly initialize t_dev to NODEV.
In ptcwakeup() do not bother to wake up a client side if it has not been
opened yet.
The old code would spuriously wakeup the client minor(0) [i.e. ttyp0
typically] or crash the kernel if that wasn't open, see PR kern/40688.
(Old names used to match the PR and test case, adjust names for
/dev/ptm[x] resp. /dev/pts/* accordingly)
To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/kern/tty.c
cvs rdiff -u -r1.124 -r1.125 src/sys/kern/tty_pty.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.242 src/sys/kern/tty.c:1.243
--- src/sys/kern/tty.c:1.242 Wed Feb 2 03:00:44 2011
+++ src/sys/kern/tty.c Sat Apr 9 06:34:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.242 2011/02/02 03:00:44 christos Exp $ */
+/* $NetBSD: tty.c,v 1.243 2011/04/09 06:34:06 martin Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.242 2011/02/02 03:00:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.243 2011/04/09 06:34:06 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2695,6 +2695,7 @@
cv_init(&tp->t_outcvf, "ttyoutf");
/* Set default line discipline. */
tp->t_linesw = ttyldisc_default();
+ tp->t_dev = NODEV;
selinit(&tp->t_rsel);
selinit(&tp->t_wsel);
for (i = 0; i < TTYSIG_COUNT; i++)
Index: src/sys/kern/tty_pty.c
diff -u src/sys/kern/tty_pty.c:1.124 src/sys/kern/tty_pty.c:1.125
--- src/sys/kern/tty_pty.c:1.124 Tue Nov 16 23:58:11 2010
+++ src/sys/kern/tty_pty.c Sat Apr 9 06:34:06 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tty_pty.c,v 1.124 2010/11/16 23:58:11 dyoung Exp $ */
+/* $NetBSD: tty_pty.c,v 1.125 2011/04/09 06:34:06 martin Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.124 2010/11/16 23:58:11 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.125 2011/04/09 06:34:06 martin Exp $");
#include "opt_ptm.h"
@@ -523,7 +523,11 @@
void
ptcwakeup(struct tty *tp, int flag)
{
- struct pt_softc *pti = pt_softc[minor(tp->t_dev)];
+ struct pt_softc *pti = NULL;
+
+ if (tp->t_dev == NODEV) return;
+
+ pti = pt_softc[minor(tp->t_dev)];
mutex_spin_enter(&tty_lock);
if (flag & FREAD) {