X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0b4e3aa066abc0728aacb4bbeb86f53f9737156e..fa4905b191e0d16b0fffd53bd565eca71d01fae0:/bsd/vfs/vfs_vnops.c diff --git a/bsd/vfs/vfs_vnops.c b/bsd/vfs/vfs_vnops.c index a16dfb167..b351d715b 100644 --- a/bsd/vfs/vfs_vnops.c +++ b/bsd/vfs/vfs_vnops.c @@ -431,6 +431,7 @@ vn_ioctl(fp, com, data, p) register struct vnode *vp = ((struct vnode *)fp->f_data); struct vattr vattr; int error; + struct vnode *ttyvp; switch (vp->v_type) { @@ -454,10 +455,11 @@ vn_ioctl(fp, com, data, p) case VBLK: error = VOP_IOCTL(vp, com, data, fp->f_flag, p->p_ucred, p); if (error == 0 && com == TIOCSCTTY) { - if (p->p_session->s_ttyvp) - vrele(p->p_session->s_ttyvp); - p->p_session->s_ttyvp = vp; VREF(vp); + ttyvp = p->p_session->s_ttyvp; + p->p_session->s_ttyvp = vp; + if (ttyvp) + vrele(ttyvp); } return (error); }