Skip to content

Commit 63bfc4c

Browse files
Nicholas Bellingergregkh
authored andcommitted
iscsi-target: Fix non-immediate TMR reference leak
commit 3fc9fb13a4b2576aeab86c62fd64eb29ab68659c upstream. This patch fixes a se_cmd->cmd_kref reference leak that can occur when a non immediate TMR is proceeded our of command sequence number order, and CMDSN_LOWER_THAN_EXP is returned by iscsit_sequence_cmd(). To address this bug, call target_put_sess_cmd() during this special case following what iscsit_process_scsi_cmd() does upon CMDSN_LOWER_THAN_EXP. Cc: Mike Christie <mchristi@redhat.com> Cc: Hannes Reinecke <hare@suse.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8709c53 commit 63bfc4c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/target/iscsi/iscsi_target.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,12 +1923,14 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
19231923

19241924
if (!(hdr->opcode & ISCSI_OP_IMMEDIATE)) {
19251925
int cmdsn_ret = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn);
1926-
if (cmdsn_ret == CMDSN_HIGHER_THAN_EXP)
1926+
if (cmdsn_ret == CMDSN_HIGHER_THAN_EXP) {
19271927
out_of_order_cmdsn = 1;
1928-
else if (cmdsn_ret == CMDSN_LOWER_THAN_EXP)
1928+
} else if (cmdsn_ret == CMDSN_LOWER_THAN_EXP) {
1929+
target_put_sess_cmd(&cmd->se_cmd);
19291930
return 0;
1930-
else if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER)
1931+
} else if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER) {
19311932
return -1;
1933+
}
19321934
}
19331935
iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn));
19341936

0 commit comments

Comments
 (0)