Fix a memory leak in __getcwd() that can occur after a filesystem

has been forcibly unmounted. If the filesystem root vnode is reached
and it has no associated mountpoint (vp->v_mount == NULL), __getcwd
would return without freeing 'buf'. Add the missing free() call.

PR:		kern/30306
Submitted by:	Mike Potanin <potanin@mccme.ru>
MFC after:	1 week
This commit is contained in:
Ian Dowse 2001-09-04 19:03:47 +00:00
parent 1106c5f173
commit 7476f7e87d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=83000

View File

@ -687,8 +687,10 @@ __getcwd(p, uap)
slash_prefixed = 0;
for (vp = fdp->fd_cdir; vp != fdp->fd_rdir && vp != rootvnode;) {
if (vp->v_flag & VROOT) {
if (vp->v_mount == NULL) /* forced unmount */
if (vp->v_mount == NULL) { /* forced unmount */
free(buf, M_TEMP);
return (EBADF);
}
vp = vp->v_mount->mnt_vnodecovered;
continue;
}