mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-05 09:14:03 +00:00
- Don't allow calls to vn_lock() with no lock type requested. Callers
which simply want a reference should use vref(). Callers which want to check validity need to hold a lock while performing any action based on that validity. vn_lock() would always release the interlock before returning making any action synchronous with the validity check impossible.
This commit is contained in:
parent
069c6953a0
commit
5634d48667
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177727
@ -854,26 +854,16 @@ vn_poll(fp, events, active_cred, td)
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that the vnode is still valid, and if so
|
||||
* acquire requested lock.
|
||||
* Acquire the requested lock and then check for validity. LK_RETRY
|
||||
* permits vn_lock to return doomed vnodes.
|
||||
*/
|
||||
int
|
||||
_vn_lock(struct vnode *vp, int flags, char *file, int line)
|
||||
{
|
||||
int error;
|
||||
|
||||
/*
|
||||
* With no lock type requested we're just polling for validity.
|
||||
*/
|
||||
if ((flags & LK_TYPE_MASK) == 0) {
|
||||
error = 0;
|
||||
if ((flags & LK_INTERLOCK) == 0)
|
||||
VI_LOCK(vp);
|
||||
if (vp->v_iflag & VI_DOOMED)
|
||||
error = ENOENT;
|
||||
VI_UNLOCK(vp);
|
||||
return (error);
|
||||
}
|
||||
VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
|
||||
("vn_lock called with no locktype."));
|
||||
do {
|
||||
error = VOP_LOCK1(vp, flags, file, line);
|
||||
flags &= ~LK_INTERLOCK; /* Interlock is always dropped. */
|
||||
|
Loading…
Reference in New Issue
Block a user