In devfs_allocv(), rather than assigning 'td = curthread', assert that
the caller passes in a td that is curthread, and consistently pass 'td' into vget(). Remove some bogus logic that passed in td or curthread conditional on td being non-NULL, which seems redundant in the face of the earlier assignment of td to curthread if td is NULL. In devfs_symlink(), cache the passed thread in 'td' so we don't have to keep retrieving it from the 'ap' structure, and assert that td is curthread (since we dereference it to get thread-local td_ucred). Use 'td' in preference to curthread for later lockmgr calls, since they are equal.
This commit is contained in:
parent
aafe09f586
commit
01be595ab3
@ -125,12 +125,11 @@ devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp, stru
|
||||
struct vnode *vp;
|
||||
struct cdev *dev;
|
||||
|
||||
if (td == NULL)
|
||||
td = curthread; /* XXX */
|
||||
KASSERT(td == curthread, ("devfs_allocv: td != curthread"));
|
||||
loop:
|
||||
vp = de->de_vnode;
|
||||
if (vp != NULL) {
|
||||
if (vget(vp, LK_EXCLUSIVE, td ? td : curthread))
|
||||
if (vget(vp, LK_EXCLUSIVE, td))
|
||||
goto loop;
|
||||
*vpp = vp;
|
||||
return (0);
|
||||
@ -849,8 +848,11 @@ devfs_symlink(ap)
|
||||
struct devfs_dirent *dd;
|
||||
struct devfs_dirent *de;
|
||||
struct devfs_mount *dmp;
|
||||
struct thread *td;
|
||||
|
||||
error = suser(ap->a_cnp->cn_thread);
|
||||
td = ap->a_cnp->cn_thread;
|
||||
KASSERT(td == curthread, ("devfs_symlink: td != curthread"));
|
||||
error = suser(td);
|
||||
if (error)
|
||||
return(error);
|
||||
dmp = VFSTODEVFS(ap->a_dvp->v_mount);
|
||||
@ -864,13 +866,13 @@ devfs_symlink(ap)
|
||||
i = strlen(ap->a_target) + 1;
|
||||
MALLOC(de->de_symlink, char *, i, M_DEVFS, M_WAITOK);
|
||||
bcopy(ap->a_target, de->de_symlink, i);
|
||||
lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, curthread);
|
||||
lockmgr(&dmp->dm_lock, LK_EXCLUSIVE, 0, td);
|
||||
#ifdef MAC
|
||||
mac_create_devfs_symlink(ap->a_cnp->cn_cred, dmp->dm_mount, dd, de);
|
||||
#endif
|
||||
TAILQ_INSERT_TAIL(&dd->de_dlist, de, de_list);
|
||||
devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, 0);
|
||||
lockmgr(&dmp->dm_lock, LK_RELEASE, 0, curthread);
|
||||
devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp, td);
|
||||
lockmgr(&dmp->dm_lock, LK_RELEASE, 0, td);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user