summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/tty.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 4701584..f82ac45 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -333,7 +333,15 @@ tty_close(struct tty *tp)
tp->t_state = 0;
knlist_clear(&tp->t_rsel.si_note, 0);
knlist_clear(&tp->t_wsel.si_note, 0);
- ttyrel(tp);
+ /*
+ * Any close with tp->t_refcnt == 1 is wrong and is
+ * an indication of a locking bug somewhere and that
+ * our open call has not been finished properly.
+ * Instead of putting an assert here we skip decrementing
+ * the refcount to work around any problems.
+ */
+ if (tp->t_refcnt > 1)
+ ttyrel(tp);
splx(s);
return (0);
}
@@ -3068,11 +3076,6 @@ ttyopen(struct cdev *dev, int flag, int mode, struct thread *td)
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