diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index cefae60b0..bafb836ad 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1719,6 +1719,9 @@ static void scst_check_reassign_sess(struct scst_session *sess) TRACE_ENTRY(); + if (tgt_dev->sess->shut_phase != SCST_SESS_SPH_READY) + goto out; + TRACE_MGMT_DBG("Checking reassignment for sess %p (initiator %s)", sess, sess->initiator_name); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 5b54d27ec..eab09a826 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -6254,6 +6254,10 @@ static int scst_init_session(struct scst_session *sess) if (res != 0) goto failed; + /* + * scst_sess_alloc_tgt_devs() must be called after session added in the + * sess_list to not race with scst_check_reassign_sess()! + */ res = scst_sess_alloc_tgt_devs(sess); failed: