summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2001-09-04 19:03:47 +0000
committeriedowse <iedowse@FreeBSD.org>2001-09-04 19:03:47 +0000
commit44040d926100921b9fdd3a8427f5660ec08e0227 (patch)
treeaa162ad43a2563b319e80cae4178b6085b2d910b /sys
parent6995cd30050939abf97ac0fa7fb42a68ce4f63a1 (diff)
downloadFreeBSD-src-44040d926100921b9fdd3a8427f5660ec08e0227.zip
FreeBSD-src-44040d926100921b9fdd3a8427f5660ec08e0227.tar.gz
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
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_cache.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index ceb3c72..af3035a 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -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;
}
OpenPOWER on IntegriCloud