From 81f80e1708a44fad2653fb798a4bf5bcd5470fb1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 16 May 2017 02:04:47 +0000 Subject: [PATCH] isert-scst: Fix a race condition that was introduced accidentally in r7184 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7186 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser_global.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iscsi-scst/kernel/isert-scst/iser_global.c b/iscsi-scst/kernel/isert-scst/iser_global.c index 82b43cbcb..cee6398a0 100644 --- a/iscsi-scst/kernel/isert-scst/iser_global.c +++ b/iscsi-scst/kernel/isert-scst/iser_global.c @@ -62,11 +62,14 @@ void isert_portal_list_remove(struct isert_portal *portal) void isert_decrease_portal_cnt(void) { + int portal_cnt; + spin_lock(&isert_glob.portal_lock); WARN_ON_ONCE(isert_glob.portal_cnt <= 0); + portal_cnt = --isert_glob.portal_cnt; spin_unlock(&isert_glob.portal_lock); - if (--isert_glob.portal_cnt == 0) + if (portal_cnt == 0) wake_up_all(&isert_glob.portal_wq); }