svn commit: r294735 - head/sys/kern
Konstantin Belousov
kib at FreeBSD.org
Mon Jan 25 16:47:22 UTC 2016
Author: kib
Date: Mon Jan 25 16:47:20 2016
New Revision: 294735
URL: https://svnweb.freebsd.org/changeset/base/294735
Log:
Don't allow opening the callout device when the callin device is already
open (in disguise as the console device). The only allowed combination
was supposed to be the callin device with the console.
Fix the assertion in ttydev_close() that was meant to detect this (it
only detected all 3 devices being open). Assert this in ttydev_open()
too.
Submitted by: bde
MFC after: 2 weeks
Modified:
head/sys/kern/tty.c
Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c Mon Jan 25 16:18:53 2016 (r294734)
+++ head/sys/kern/tty.c Mon Jan 25 16:47:20 2016 (r294735)
@@ -263,10 +263,10 @@ ttydev_open(struct cdev *dev, int oflags
/*
* Make sure the "tty" and "cua" device cannot be opened at the
- * same time.
+ * same time. The console is a "tty" device.
*/
if (TTY_CALLOUT(tp, dev)) {
- if (tp->t_flags & TF_OPENED_IN) {
+ if (tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) {
error = EBUSY;
goto done;
}
@@ -319,6 +319,8 @@ ttydev_open(struct cdev *dev, int oflags
tp->t_flags |= TF_OPENED_OUT;
else
tp->t_flags |= TF_OPENED_IN;
+ MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 ||
+ (tp->t_flags & TF_OPENED_OUT) == 0);
done: tp->t_flags &= ~TF_OPENCLOSE;
cv_broadcast(&tp->t_dcdwait);
@@ -338,7 +340,8 @@ ttydev_close(struct cdev *dev, int fflag
* Don't actually close the device if it is being used as the
* console.
*/
- MPASS((tp->t_flags & TF_OPENED) != TF_OPENED);
+ MPASS((tp->t_flags & (TF_OPENED_CONS | TF_OPENED_IN)) == 0 ||
+ (tp->t_flags & TF_OPENED_OUT) == 0);
if (dev == dev_console)
tp->t_flags &= ~TF_OPENED_CONS;
else
More information about the svn-src-all
mailing list