diff --git a/module/os/windows/zfs/zfs_vnops_windows.c b/module/os/windows/zfs/zfs_vnops_windows.c index 349dfa1a844c..5eb06b2da664 100644 --- a/module/os/windows/zfs/zfs_vnops_windows.c +++ b/module/os/windows/zfs/zfs_vnops_windows.c @@ -132,6 +132,16 @@ zfs_AcquireForLazyWrite(void *Context, BOOLEAN Wait) struct vnode *vp = fo->FsContext; dprintf("%s:fo %p\n", __func__, fo); + if (unlikely((zmo->vpb->Flags & VPB_MOUNTED) == 0)) { + dprintf("%s: fo %p not mounted\n", __func__, fo); + return (FALSE); + } + + if (unlikely(zfsvfs == NULL)) { + dprintf("%s: fo %p already freed zfsvfs\n", __func__, fo); + return (FALSE); + } + /* Confirm we are mounted, and stop unmounting */ if (vfs_busy(zfsvfs->z_vfs, 0) != 0) return (FALSE); diff --git a/module/os/windows/zfs/zfs_vnops_windows_mount.c b/module/os/windows/zfs/zfs_vnops_windows_mount.c index 4673a8fbfedf..1aabdbf87a04 100644 --- a/module/os/windows/zfs/zfs_vnops_windows_mount.c +++ b/module/os/windows/zfs/zfs_vnops_windows_mount.c @@ -1583,6 +1583,12 @@ zfs_windows_unmount(zfs_cmd_t *zc) if (error) goto out_unlock; + if (zmo_dcb != NULL) { + // zfs_vfs_unmount already freed the zfsvfs, but + // a reference still exists in the DCB. + vfs_setfsprivate(zmo_dcb, NULL); + } + // Release devices IoDeleteSymbolicLink(&zmo->symlink_name);