From 6f27c4cadd29eb9b850c1c66bf71ef9ba119b955 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 2 Aug 2024 17:45:00 -0700 Subject: [PATCH] [2.2.5-only] Make 'rmmod zfs' work after zfs-2.2.4 (#16406) db65272ae was added to zfs-2.2.4 to stub in the VDEV_PROP_RAIDZ_EXPANDING enum without adding the RAIDz expansion feature. This was needed to provide the right enum count for when the VDEV_PROP_SLOW_IO proprieties got added. This had the unfortunate side effect of breaking module removal though. Specifically, with the VDEV_PROP_RAIDZ_EXPANDING stub added, the module would correctly omit making kobjects for the RAIDz expansion vdev property, but then would try to blindly remove its non-existent kobjects during module unload. This commit fixes the issue by checking for an uninitialized kobject. Fixes: #16249 Signed-off-by: Tony Hutter Reviewed-by: Brian Behlendorf Reviewed-by: Ameer Hamza Reviewed-by: Tino Reichardt --- module/os/linux/zfs/zfs_sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/module/os/linux/zfs/zfs_sysfs.c b/module/os/linux/zfs/zfs_sysfs.c index e2431fe8a8..b8cc682ad5 100644 --- a/module/os/linux/zfs/zfs_sysfs.c +++ b/module/os/linux/zfs/zfs_sysfs.c @@ -110,8 +110,17 @@ zfs_kobj_fini(zfs_mod_kobj_t *zkobj) } /* kobject_put() will call zfs_kobj_release() to release memory */ - kobject_del(&zkobj->zko_kobj); - kobject_put(&zkobj->zko_kobj); + /* + * Special case note: + * + * We have to check for 'zkobj->zko_kobj.name != NULL' as + * a workaround for #16249 which was added to zfs-2.2.4 + * and fixed (with this change) in zfs-2.2.5. + */ + if (zkobj->zko_kobj.name != NULL) { + kobject_del(&zkobj->zko_kobj); + kobject_put(&zkobj->zko_kobj); + } } static void