From 231b3cddc22a5b26c4ad32e9ea03d9bd95f62923 Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 8 Apr 2010 08:58:18 +0000 Subject: Do not leak master pty or ptmx vnode. Report and test case by: Petr Salinger Reviewed by: ed MFC after: 1 week --- sys/kern/tty_pts.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 5cfbc71..51f2641 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -575,6 +575,15 @@ ptsdev_close(struct file *fp, struct thread *td) tty_lock(tp); tty_rel_gone(tp); + /* + * Open of /dev/ptmx or /dev/ptyXX changes the type of file + * from DTYPE_VNODE to DTYPE_PTS. vn_open() increases vnode + * use count, we need to decrement it, and possibly do other + * required cleanup. + */ + if (fp->f_vnode != NULL) + return (vnops.fo_close(fp, td)); + return (0); } -- cgit v1.1