HomeFreeBSD

Linux SPL module init: Handle memory allocation failures correctly

Description

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

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Sep 8 2022, 5:28 PM
GitHub <noreply@github.com>Committed on Sep 8 2022, 5:28 PM
Parents
rGdff541f698d6: Fix build on FreeBSD/powerpc64*
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG380b08098edf: Linux SPL module init: Handle memory allocation failures correctly (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Sep 8 2022, 5:28 PM