diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 773d745e7371..7dbd58f795cc 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -745,6 +745,11 @@ ufs_lookup_ino(struct vnode *vdp, struct vnode **vpp, struct componentname *cnp, *vpp = vdp; } else { error = VFS_VGET(pdp->v_mount, ino, cnp->cn_lkflags, &tdp); + if (error == 0 && VTOI(tdp)->i_mode == 0) { + vgone(tdp); + vput(tdp); + error = ENOENT; + } if (error) return (error); *vpp = tdp; diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 80a98ee1c83d..4813ac7db763 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -240,6 +240,8 @@ ufs_fhtovp(mp, ufhp, flags, vpp) ip = VTOI(nvp); if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen || ip->i_effnlink <= 0) { + if (ip->i_mode == 0) + vgone(nvp); vput(nvp); *vpp = NULLVP; return (ESTALE);