summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/os/freebsd/zfs/kmod_core.c2
-rw-r--r--module/os/linux/zfs/zfs_ioctl_os.c2
-rw-r--r--module/zfs/zfs_ioctl.c15
3 files changed, 12 insertions, 7 deletions
diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c
index 89f499640..dce73577e 100644
--- a/module/os/freebsd/zfs/kmod_core.c
+++ b/module/os/freebsd/zfs/kmod_core.c
@@ -201,6 +201,8 @@ zfsdev_close(void *data)
zfs_onexit_destroy(zs->zs_onexit);
zfs_zevent_destroy(zs->zs_zevent);
mutex_exit(&zfsdev_state_lock);
+ zs->zs_onexit = NULL;
+ zs->zs_zevent = NULL;
}
static int
diff --git a/module/os/linux/zfs/zfs_ioctl_os.c b/module/os/linux/zfs/zfs_ioctl_os.c
index 457f4e8ea..52c5ed883 100644
--- a/module/os/linux/zfs/zfs_ioctl_os.c
+++ b/module/os/linux/zfs/zfs_ioctl_os.c
@@ -148,6 +148,8 @@ zfsdev_state_destroy(struct file *filp)
zs->zs_minor = -1;
zfs_onexit_destroy(zs->zs_onexit);
zfs_zevent_destroy(zs->zs_zevent);
+ zs->zs_onexit = NULL;
+ zs->zs_zevent = NULL;
return (0);
}
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index d0d5207b4..10b37a4ad 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -7609,19 +7609,20 @@ out:
void
zfs_kmod_fini(void)
{
- zfsdev_state_t *zs, *zsprev = NULL;
+ zfsdev_state_t *zs, *zsnext = NULL;
zfsdev_detach();
mutex_destroy(&zfsdev_state_lock);
- for (zs = zfsdev_state_list; zs != NULL; zs = zs->zs_next) {
- if (zsprev)
- kmem_free(zsprev, sizeof (zfsdev_state_t));
- zsprev = zs;
+ for (zs = zfsdev_state_list; zs != NULL; zs = zsnext) {
+ zsnext = zs->zs_next;
+ if (zs->zs_onexit)
+ zfs_onexit_destroy(zs->zs_onexit);
+ if (zs->zs_zevent)
+ zfs_zevent_destroy(zs->zs_zevent);
+ kmem_free(zs, sizeof (zfsdev_state_t));
}
- if (zsprev)
- kmem_free(zsprev, sizeof (zfsdev_state_t));
zfs_fini();
spa_fini();