mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 19:28:53 +03:00
Linux SPL module init: Handle memory allocation failures correctly
Upon inspection of our code, I noticed that we assume that __alloc_percpu() cannot fail, and while it probably never has failed in practice, technically, it can fail, so we should handle that. Additionally, we incorrectly assume that `taskq_create()` in spl_kmem_cache_init() cannot fail. The same remark applies to it. Lastly, `spl-init()` failures should always return negative error values, but in some places, we are returning positive 1, which is incorrect. We change those values to their correct error codes. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #13847
This commit is contained in:
@@ -1379,7 +1379,7 @@ spl_taskq_init(void)
|
||||
system_taskq = taskq_create("spl_system_taskq", MAX(boot_ncpus, 64),
|
||||
maxclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE|TASKQ_DYNAMIC);
|
||||
if (system_taskq == NULL)
|
||||
return (1);
|
||||
return (-ENOMEM);
|
||||
|
||||
system_delay_taskq = taskq_create("spl_delay_taskq", MAX(boot_ncpus, 4),
|
||||
maxclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE|TASKQ_DYNAMIC);
|
||||
@@ -1388,7 +1388,7 @@ spl_taskq_init(void)
|
||||
cpuhp_remove_multi_state(spl_taskq_cpuhp_state);
|
||||
#endif
|
||||
taskq_destroy(system_taskq);
|
||||
return (1);
|
||||
return (-ENOMEM);
|
||||
}
|
||||
|
||||
dynamic_taskq = taskq_create("spl_dynamic_taskq", 1,
|
||||
@@ -1399,7 +1399,7 @@ spl_taskq_init(void)
|
||||
#endif
|
||||
taskq_destroy(system_taskq);
|
||||
taskq_destroy(system_delay_taskq);
|
||||
return (1);
|
||||
return (-ENOMEM);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user