summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-02-08 11:15:36 +0000
committerkib <kib@FreeBSD.org>2016-02-08 11:15:36 +0000
commitbc0cc9f20c1e90100fdf972cce746b77614f3132 (patch)
tree798132ab7fef98015cd1c2f6689e2974fcb1d333 /sys/kern/tty.c
parent3078b388e3205a7974daa71624945c943dbe1273 (diff)
downloadFreeBSD-src-bc0cc9f20c1e90100fdf972cce746b77614f3132.zip
FreeBSD-src-bc0cc9f20c1e90100fdf972cce746b77614f3132.tar.gz
MFC r294735:
Don't allow opening the callout device when the callin device is already open (in disguise as the console device). Approved by: re (gjb)
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index a5a6690..76904a7 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -266,10 +266,10 @@ ttydev_open(struct cdev *dev, int oflags, int devtype __unused,
/*
* 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;
}
@@ -322,6 +322,8 @@ ttydev_open(struct cdev *dev, int oflags, int devtype __unused,
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);
@@ -342,7 +344,8 @@ ttydev_close(struct cdev *dev, int fflag, int devtype __unused,
* 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
OpenPOWER on IntegriCloud