reactor: Check error return for spdk_thread_lib_init_ext.

DPDK may use this NULL pointer to access its member,
And then got segmentation fault. But we only need it
exit or report normal error.

To minimize the impact, and to prevent these going on,
we add check the error return for creating NULL mempool
in spdk_thread_lib_init_ext in spdk_reactors_init.

when error returning from spdk_thread_lib_init_ext in spdk_reactors_init.
It contains thread_lib_init which reports error for failed mempool.

Thus, codes will return and will not cause segmentation fault.

Fixes issue #2620.

Signed-off-by: yidong0635 <dongx.yi@intel.com>
Change-Id: I63369fdaeb231196e8f8daa826eb5b057ed829b8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13842
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Michal Berger <michal.berger@intel.com>
This commit is contained in:
yidong0635 2022-08-04 13:33:28 +08:00 committed by Tomasz Zawadzki
parent c9eb502a4a
commit 5de98ef86c

View File

@ -246,8 +246,15 @@ spdk_reactors_init(size_t msg_mempool_size)
memset(g_reactors, 0, (g_reactor_count) * sizeof(struct spdk_reactor));
spdk_thread_lib_init_ext(reactor_thread_op, reactor_thread_op_supported,
sizeof(struct spdk_lw_thread), msg_mempool_size);
rc = spdk_thread_lib_init_ext(reactor_thread_op, reactor_thread_op_supported,
sizeof(struct spdk_lw_thread), msg_mempool_size);
if (rc != 0) {
SPDK_ERRLOG("Initialize spdk thread lib failed\n");
spdk_mempool_free(g_spdk_event_mempool);
free(g_reactors);
free(g_core_infos);
return rc;
}
SPDK_ENV_FOREACH_CORE(i) {
reactor_construct(&g_reactors[i], i);