summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2006-09-30 08:11:51 +0000
committermbr <mbr@FreeBSD.org>2006-09-30 08:11:51 +0000
commitb63df50b58ae257b3231a2d7abfc8c4fd6e7fdf4 (patch)
tree532b3919a90fe9a3cae0e14e82f669b793f0de13 /sys/kern/tty.c
parent8cff3b898fb26f0c71481bc9a3053ff0f965b865 (diff)
downloadFreeBSD-src-b63df50b58ae257b3231a2d7abfc8c4fd6e7fdf4.zip
FreeBSD-src-b63df50b58ae257b3231a2d7abfc8c4fd6e7fdf4.tar.gz
Any call of tty_close() with a tty refcount of <= 1 is wrong and we will
free the tty in this case. This is a workaround until the underlaying devfs/tty problems are fixed. MFC after: 1 day
Diffstat (limited to 'sys/kern/tty.c')
-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