From 93e0f56a01ff93e4bf7db2124dd624349257f1dc Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 15 Nov 2007 15:54:53 +0000 Subject: [PATCH] Fixes race found by Anton Novodvorsky git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@222 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_targ.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2781db396..9c910dd39 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1835,9 +1835,10 @@ out: return; } -static int scst_send_to_midlev(struct scst_cmd *cmd) +static int scst_send_to_midlev(struct scst_cmd **active_cmd) { int res, rc; + struct scst_cmd *cmd = *active_cmd; struct scst_tgt_dev *tgt_dev = cmd->tgt_dev; struct scst_device *dev = cmd->dev; typeof(tgt_dev->expected_sn) expected_sn; @@ -1921,6 +1922,7 @@ exec: "thread context, rescheduling"); res = SCST_CMD_STATE_RES_NEED_THREAD; scst_dec_on_dev_cmd(cmd); + *active_cmd = cmd; if (count != 0) goto out_unplug; else @@ -2885,7 +2887,7 @@ void scst_process_active_cmd(struct scst_cmd *cmd, int context) cmd->tag); break; } - res = scst_send_to_midlev(cmd); + res = scst_send_to_midlev(&cmd); /* !! At this point cmd, sess & tgt_dev can be already freed !! */ break;