From 9c3c488e0cff58386919b069b73db3d376d4d27a Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 21 Oct 2019 11:26:55 +0900 Subject: [PATCH] lib/iscsi: Fix NULL pointer access for logout with close connection conn->sess->session_type must be accessed when conn->sess is not NULL. Signed-off-by: Shuhei Matsumoto Change-Id: I3d41443352b65ee5ef4cc1f0d152b9e3221975c9 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471877 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Ziye Yang Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/iscsi/iscsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index d8305ac37..615977771 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -2483,12 +2483,12 @@ iscsi_pdu_hdr_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "reason=%d, ITT=%x, cid=%d\n", reqh->reason, task_tag, cid); - if (reqh->reason != 0 && conn->sess->session_type == SESSION_TYPE_DISCOVERY) { - SPDK_ERRLOG("only logout with close the session reason can be in discovery session"); - return SPDK_ISCSI_CONNECTION_FATAL; - } - if (conn->sess != NULL) { + if (reqh->reason != 0 && conn->sess->session_type == SESSION_TYPE_DISCOVERY) { + SPDK_ERRLOG("only logout with close the session reason can be in discovery session\n"); + return SPDK_ISCSI_CONNECTION_FATAL; + } + SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "CmdSN=%u, ExpStatSN=%u, StatSN=%u, ExpCmdSN=%u, MaxCmdSN=%u\n", pdu->cmd_sn, ExpStatSN, conn->StatSN,