From 792737cf4d98d3af06c2946642a2cf3409e03e1b Mon Sep 17 00:00:00 2001 From: iedowse Date: Fri, 28 Jun 2002 20:06:47 +0000 Subject: In vn_mkdir(), use vrele() instead of vput() on the parent directory vnode in the case that the target exists and is the same vnode as the parent (i.e. "mkdir ."). The namei() call does not leave the vnode locked in this case even though you might expect it to. This bug was mostly harmless in practice because unlocking an already unlocked vnode currently does not trigger any panics or warnings. Reviewed by: jeff --- sys/kern/vfs_extattr.c | 10 +++++++++- sys/kern/vfs_syscalls.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 05e4fb6..41e4d28 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -3652,7 +3652,15 @@ restart: if (vp != NULL) { NDFREE(&nd, NDF_ONLY_PNBUF); vrele(vp); - vput(nd.ni_dvp); + /* + * XXX namei called with LOCKPARENT but not LOCKLEAF has + * the strange behaviour of leaving the vnode unlocked + * if the target is the same vnode as the parent. + */ + if (vp == nd.ni_dvp) + vrele(nd.ni_dvp); + else + vput(nd.ni_dvp); return (EEXIST); } if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 05e4fb6..41e4d28 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3652,7 +3652,15 @@ restart: if (vp != NULL) { NDFREE(&nd, NDF_ONLY_PNBUF); vrele(vp); - vput(nd.ni_dvp); + /* + * XXX namei called with LOCKPARENT but not LOCKLEAF has + * the strange behaviour of leaving the vnode unlocked + * if the target is the same vnode as the parent. + */ + if (vp == nd.ni_dvp) + vrele(nd.ni_dvp); + else + vput(nd.ni_dvp); return (EEXIST); } if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { -- cgit v1.1