Fix race between queueing the pdu and update the task data
After we have called iscsi_queue_pdu from iscsi_scsi_command_async the pdu might have already completed if we are using multithreading so we should not dereference pdu at that point. Move the assignment of task->cmdsn and task->itt we need for task management into iscsi_pdu_set_cmdsn instead. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -267,6 +267,7 @@ iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
|
||||
/* lun */
|
||||
iscsi_pdu_set_lun(pdu, lun);
|
||||
pdu->lun = lun;
|
||||
task->lun = lun;
|
||||
|
||||
/* expxferlen */
|
||||
iscsi_pdu_set_expxferlen(pdu, task->expxferlen);
|
||||
@@ -290,11 +291,6 @@ iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
|
||||
iscsi_send_unsolicited_data_out(iscsi, pdu);
|
||||
}
|
||||
|
||||
/* remember cmdsn and itt so we can use task management */
|
||||
task->cmdsn = pdu->cmdsn;
|
||||
task->itt = pdu->itt;
|
||||
task->lun = lun;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user