scsi: qla2xxx: Fix a race condition between aborting and completing a SCSI command
authorBart Van Assche <bvanassche@acm.org>
Fri, 9 Aug 2019 03:02:06 +0000 (20:02 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Dec 2019 19:08:30 +0000 (20:08 +0100)
commit95000d33752d22d46838a462afaaa3107a5dfab2
tree16da64275d158d526bb3bc76d7f7a634da5db555
parentb4edc7157b94dba1c2b0d867cfcdf38b5d1cd199
scsi: qla2xxx: Fix a race condition between aborting and completing a SCSI command

[ Upstream commit 85cffefa09e448906a6f0bc20f422d75a18675bd ]

Instead of allocating a struct srb dynamically from inside .queuecommand(),
set qla2xxx_driver_template.cmd_size such that struct scsi_cmnd and struct
srb are contiguous. Do not call QLA_QPAIR_MARK_BUSY() /
QLA_QPAIR_MARK_NOT_BUSY() for SRBs associated with SCSI commands. That is
safe because scsi_remove_host() is called before queue pairs are deleted
and scsi_remove_host() waits for all outstanding SCSI commands to finish.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_os.c