Skip to content

Commit c130480

Browse files
author
Nicholas Bellinger
committed
target: Fix se_cmd->state_list leak regression during WRITE failure
This patch addresses a v3.11 specific regression where se_cmd->state_list was being leaked during a fabric WRITE failure, when the fabric releases an associated se_cmd descriptor before I/O submission occurs, and normal fast path callbacks have a chance to call target_remove_from_state_list(). It was manifesting with Poison overwritten messages with iscsi-target once an ImmediateData payload CRC32C failure occured. This bug was originally introduced during v3.11-rc1 with the following commit: commit 0b66818 Author: Nicholas Bellinger <[email protected]> Date: Thu Jun 6 01:36:41 2013 -0700 target: Drop unnecessary CMD_T_DEV_ACTIVE check from transport_lun_remove_cmd Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 28aaa95 commit c130480

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/target/target_core_transport.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,7 @@ static void transport_write_pending_qf(struct se_cmd *cmd)
21342134

21352135
int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
21362136
{
2137+
unsigned long flags;
21372138
int ret = 0;
21382139

21392140
if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) {
@@ -2144,6 +2145,16 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
21442145
} else {
21452146
if (wait_for_tasks)
21462147
transport_wait_for_tasks(cmd);
2148+
/*
2149+
* Handle WRITE failure case where transport_generic_new_cmd()
2150+
* has already added se_cmd to state_list, but fabric has
2151+
* failed command before I/O submission.
2152+
*/
2153+
if (cmd->state_active) {
2154+
spin_lock_irqsave(&cmd->t_state_lock, flags);
2155+
target_remove_from_state_list(cmd);
2156+
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2157+
}
21472158

21482159
if (cmd->se_lun)
21492160
transport_lun_remove_cmd(cmd);

0 commit comments

Comments
 (0)