summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-02-14 18:57:40 +0000
committerkib <kib@FreeBSD.org>2016-02-14 18:57:40 +0000
commit469449d6586f2d6312a6f35957be890940f40ba7 (patch)
tree696b8a6345c405d2741c034a0fd3b37a4eac8d00 /sys/kern/tty.c
parentc1aec037c122dcfdea3e2f0b0212dc2e28f0f09e (diff)
downloadFreeBSD-src-469449d6586f2d6312a6f35957be890940f40ba7.zip
FreeBSD-src-469449d6586f2d6312a6f35957be890940f40ba7.tar.gz
MFC r294598:
In tty_dealloc(), clear the queues. Approved by: re (marius)
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index ddde7b3..0e352a6 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -215,7 +215,7 @@ ttydev_leave(struct tty *tp)
ttydisc_close(tp);
- /* Destroy associated buffers already. */
+ /* Free i/o queues now since they might be large. */
ttyinq_free(&tp->t_inq);
tp->t_inlow = 0;
ttyoutq_free(&tp->t_outq);
@@ -1052,10 +1052,15 @@ tty_dealloc(void *arg)
{
struct tty *tp = arg;
- /* Make sure we haven't leaked buffers. */
- MPASS(ttyinq_getsize(&tp->t_inq) == 0);
- MPASS(ttyoutq_getsize(&tp->t_outq) == 0);
-
+ /*
+ * ttyydev_leave() usually frees the i/o queues earlier, but it is
+ * not always called between queue allocation and here. The queues
+ * may be allocated by ioctls on a pty control device without the
+ * corresponding pty slave device ever being open, or after it is
+ * closed.
+ */
+ ttyinq_free(&tp->t_inq);
+ ttyoutq_free(&tp->t_outq);
seldrain(&tp->t_inpoll);
seldrain(&tp->t_outpoll);
knlist_destroy(&tp->t_inpoll.si_note);
OpenPOWER on IntegriCloud