diff --git a/module/os/windows/zfs/zfs_vnops_windows.c b/module/os/windows/zfs/zfs_vnops_windows.c index 349dfa1a844c..6db5e0f6afff 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 ((zmo->vpb->Flags & VPB_MOUNTED) == 0) { + dprintf("%s:fo not mounted\n", __func__); + return (FALSE); + } + + if (zfsvfs == NULL) { + dprintf("%s:fo already freed zfsvfs\n", __func__); + 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);