iscsi: fix a memory leak in error handling

When function returned from the error handling the mempool on
'sess' was not released which lead to a memory leak.

Fixes issue #2393.

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Change-Id: Ida3651e9369fb5c4948969480d398a723b2cb6a2
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11714
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Weiguo Li 2022-02-23 21:10:28 +08:00 committed by Jim Harris
parent 30af49f77d
commit e685574f76

View File

@ -582,6 +582,7 @@ create_iscsi_sess(struct spdk_iscsi_conn *conn,
sess->conns = calloc(sess->MaxConnections, sizeof(*sess->conns));
if (!sess->conns) {
spdk_mempool_put(g_iscsi.session_pool, (void *)sess);
SPDK_ERRLOG("calloc() failed for connection array\n");
return -ENOMEM;
}