aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/zfs_ioctl.c
diff options
context:
space:
mode:
authorJorgen Lundman <[email protected]>2020-08-14 07:03:23 +0900
committerGitHub <[email protected]>2020-08-13 15:03:23 -0700
commitfaa296c73c7ccd535c0874d4f7e8f7c4ea43eea6 (patch)
tree2fb84bfdea8f4f357b66d125d1596748edff0abd /module/zfs/zfs_ioctl.c
parentf67f5832eca415055e1eaf6cdc100f24ae53487a (diff)
Release onexit/events with any missed zfsdev_state
Linux and FreeBSD will most likely never see this issue. On macOS when kext is unloaded, but zed is still connected, zed will be issued ENODEV. As the cdevsw is released, the kernel will not have zfsdev_release() called to release minor/onexit/events, and it "leaks". This ensures it is cleaned up before unload. Changed the for loop from zsprev, to zsnext style, for less code duplication. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Jorgen Lundman <[email protected]> Closes #10700
Diffstat (limited to 'module/zfs/zfs_ioctl.c')
-rw-r--r--module/zfs/zfs_ioctl.c15
1 files changed, 8 insertions, 7 deletions
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();