aboutsummaryrefslogtreecommitdiffstats
path: root/module/os
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2021-03-12 19:09:15 -0500
committerTony Hutter <[email protected]>2021-06-23 13:22:14 -0700
commit525a7037c7692af4cc41dd4867c9bfe60d1d15c2 (patch)
tree1205059c0904c3b051c7d59e888a2260fa26e81a /module/os
parent789f3d0e5646b7154ce183c90f9cbc4e1138fa7d (diff)
FreeBSD: Clean up zfsdev_close to match Linux
Resolve some oddities in zfsdev_close() which could result in a panic and were not present in the equivalent function for Linux. - Remove unused definition ZFS_MIN_MINOR - FreeBSD: Simplify zfsdev state destruction - Assert zs_minor is valid in zfsdev_close - Make locking around zfsdev state match Linux Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #11720
Diffstat (limited to 'module/os')
-rw-r--r--module/os/freebsd/zfs/kmod_core.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c
index c11d4dbcf..d5ba0d93a 100644
--- a/module/os/freebsd/zfs/kmod_core.c
+++ b/module/os/freebsd/zfs/kmod_core.c
@@ -182,23 +182,21 @@ out:
static void
zfsdev_close(void *data)
{
- zfsdev_state_t *zs, *zsp = data;
+ zfsdev_state_t *zs = data;
+
+ ASSERT(zs != NULL);
mutex_enter(&zfsdev_state_lock);
- for (zs = zfsdev_state_list; zs != NULL; zs = zs->zs_next) {
- if (zs == zsp)
- break;
- }
- if (zs == NULL || zs->zs_minor <= 0) {
- mutex_exit(&zfsdev_state_lock);
- return;
- }
+
+ ASSERT(zs->zs_minor != 0);
+
zs->zs_minor = -1;
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;
+
+ mutex_exit(&zfsdev_state_lock);
}
static int