If vn_open_vnode() succeeded in opening the vnode, but subsequent

advisory lock cannot be obtained, prevent double-close of the vnode in
vn_close() called from the fdrop(), by resetting file' f_ops methods.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
kib 2013-12-17 17:31:16 +00:00
parent 6ef68a4208
commit b6824d8c77

View File

@ -313,6 +313,9 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
vn_lock(vp, lock_flags | LK_RETRY);
(void)VOP_CLOSE(vp, fmode, cred, td);
vn_finished_write(mp);
/* Prevent second close from fdrop()->vn_close(). */
if (fp != NULL)
fp->f_ops= &badfileops;
return (error);
}
fp->f_flag |= FHASLOCK;