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 <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449717
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Changpeng Liu 2019-03-31 21:36:50 -04:00 committed by Jim Harris
parent e87e8263df
commit 790c47d479
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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);
}