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:
Richard Yao
2022-09-08 13:28:20 -04:00
committed by GitHub
parent dff541f698
commit 380b08098e
5 changed files with 18 additions and 7 deletions
+3
View File
@@ -1452,6 +1452,9 @@ spl_kmem_cache_init(void)
spl_kmem_cache_kmem_threads * 8, INT_MAX,
TASKQ_PREPOPULATE | TASKQ_DYNAMIC);
if (spl_kmem_cache_taskq == NULL)
return (-ENOMEM);
return (0);
}