Commit 7d93603d authored by Bart Van Assche's avatar Bart Van Assche Committed by Greg Kroah-Hartman

target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd()


[ Upstream commit cfe2b621 ]

Avoid that cmd->se_cmd.se_tfo is read after a command has already been
freed.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Mike Christie <mchristi@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 09f29c7a
...@@ -674,6 +674,7 @@ static int iscsit_add_reject_from_cmd( ...@@ -674,6 +674,7 @@ static int iscsit_add_reject_from_cmd(
unsigned char *buf) unsigned char *buf)
{ {
struct iscsi_conn *conn; struct iscsi_conn *conn;
const bool do_put = cmd->se_cmd.se_tfo != NULL;
if (!cmd->conn) { if (!cmd->conn) {
pr_err("cmd->conn is NULL for ITT: 0x%08x\n", pr_err("cmd->conn is NULL for ITT: 0x%08x\n",
...@@ -704,7 +705,7 @@ static int iscsit_add_reject_from_cmd( ...@@ -704,7 +705,7 @@ static int iscsit_add_reject_from_cmd(
* Perform the kref_put now if se_cmd has already been setup by * Perform the kref_put now if se_cmd has already been setup by
* scsit_setup_scsi_cmd() * scsit_setup_scsi_cmd()
*/ */
if (cmd->se_cmd.se_tfo != NULL) { if (do_put) {
pr_debug("iscsi reject: calling target_put_sess_cmd >>>>>>\n"); pr_debug("iscsi reject: calling target_put_sess_cmd >>>>>>\n");
target_put_sess_cmd(&cmd->se_cmd); target_put_sess_cmd(&cmd->se_cmd);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment