From 790c47d479bfc343833a49af4ae802c036fa3eef Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Sun, 31 Mar 2019 21:36:50 -0400 Subject: [PATCH] iscsi: fix up segment fault due to failed initialization My iSCSI target reported segment fault after memory allocation failure, and add the addtional check here can fix the issue. Change-Id: Iee3e497d7028fbface6d110c78e73965ef0f178b Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449717 Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: yidong0635 Tested-by: SPDK CI Jenkins --- lib/iscsi/conn.c | 2 +- lib/iscsi/iscsi_subsystem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 3acc9b14d..77f25a2a2 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -112,7 +112,7 @@ free_conn(struct spdk_iscsi_conn *conn) static struct spdk_iscsi_conn * find_iscsi_connection_by_id(int cid) { - if (g_conns_array[cid].is_valid == 1) { + if (g_conns_array != MAP_FAILED && g_conns_array[cid].is_valid == 1) { return &g_conns_array[cid]; } else { return NULL; diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index 5c44cd568..9f8e070e3 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -257,7 +257,7 @@ iscsi_initialize_all_pools(void) static void iscsi_check_pool(struct spdk_mempool *pool, size_t count) { - if (spdk_mempool_count(pool) != count) { + if (pool && spdk_mempool_count(pool) != count) { SPDK_ERRLOG("spdk_mempool_count(%s) == %zu, should be %zu\n", spdk_mempool_get_name(pool), spdk_mempool_count(pool), count); }