From bef485b20ffdf6b7cef5ab72fb5cd475a4011883 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 26 Nov 2010 21:28:38 +0000 Subject: [PATCH] Simplify scst_free_session() by invoking wake_up_all() while scst_mutex is held. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2844 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 4809b12a8..b9311809e 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -3962,9 +3962,6 @@ void scst_free_session(struct scst_session *sess) scst_sess_free_tgt_devs(sess); #ifndef CONFIG_SCST_PROC - /* tgt will stay alive at least until its sysfs alive */ - kobject_get(&sess->tgt->tgt_kobj); - mutex_unlock(&scst_mutex); scst_sess_sysfs_del(sess); mutex_lock(&scst_mutex); @@ -3980,19 +3977,15 @@ void scst_free_session(struct scst_session *sess) TRACE_DBG("Removing session %p from acg %s", sess, sess->acg->acg_name); list_del(&sess->acg_sess_list_entry); -#ifdef CONFIG_SCST_PROC /* Called under lock to protect from too early tgt release */ wake_up_all(&sess->tgt->unreg_waitQ); -#endif + /* + * NOTE: do not dereference the sess->tgt pointer after scst_mutex + * has been unlocked, because it can be already dead!! + */ mutex_unlock(&scst_mutex); -#ifndef CONFIG_SCST_PROC - wake_up_all(&sess->tgt->unreg_waitQ); - - kobject_put(&sess->tgt->tgt_kobj); -#endif - kfree(sess->transport_id); kfree(sess->initiator_name);