From d83c11c1a3a5997a5f3fc070f612653eddd5bae6 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 29 Nov 2010 17:12:53 +0000 Subject: [PATCH] Fix rarely possible race between scst_free_session() and scst_check_reassign_sess() git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2867 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 3 +++ scst/src/scst_targ.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index b9311809e..89cf055ca 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1716,6 +1716,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 61adf4337..9d061dcbd 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -6168,6 +6168,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: