summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2006-09-23 14:52:46 +0000
committermbr <mbr@FreeBSD.org>2006-09-23 14:52:46 +0000
commit9af53fcaabbc08489f360aaebe10bb92a9f7d9a6 (patch)
treeb7fbc096684dfc7283496963c1653cc56c0b4fb9 /sys/kern/tty.c
parentb8fd741213327cb2814fcafff57841e373a3df81 (diff)
downloadFreeBSD-src-9af53fcaabbc08489f360aaebe10bb92a9f7d9a6.zip
FreeBSD-src-9af53fcaabbc08489f360aaebe10bb92a9f7d9a6.tar.gz
Check for tp->t_refcnt == 0 before doing anything in tty_open().
PR: 103520 MFC after: 1 week
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index f5b7d91..4701584 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -3067,6 +3067,12 @@ ttyopen(struct cdev *dev, int flag, int mode, struct thread *td)
struct tty *tp;
tp = dev->si_tty;
+
+ /* XXX It can happen that devfs_open calls us with tp->t_refcnt == 0 */
+ if (tp == NULL || tp->t_refcnt == 0) {
+ return (ENXIO);
+ }
+
s = spltty();
/*
* We jump to this label after all non-interrupted sleeps to pick
OpenPOWER on IntegriCloud