iscsi-scst: handle a case in target_del() where the target was already freed

target_del() calls handle_iscsi_events() which may recursively call target_del().
The 1st target_del() may resume its execution after the target object was already freed.

Signed-off-by: Erez Zilber <erezzi.list@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6908 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2016-07-02 01:42:49 +00:00
parent aa18a4bcb5
commit 0c2fd8e564

View File

@@ -357,6 +357,13 @@ int target_del(u32 tid, u32 cookie)
/* We might need to handle session(s) removal event(s) from the kernel */
while (handle_iscsi_events(nl_fd, false) == 0);
/* Someone else may have already freed the target object by now. */
target = target_find_by_id(tid);
if (!target) {
log_info("%s: the target with tid = %u was already freed", __func__, tid);
return 0;
}
if (list_empty(&target->sessions_list))
break;