diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index ceb3c7245bcd..af3035a4cfbe 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; }