Skip to content

Commit fc0cba0

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Wait for io return on terminate rport
System crash due to use after free. Current code allows terminate_rport_io to exit before making sure all IOs has returned. For FCP-2 device, IO's can hang on in HW because driver has not tear down the session in FW at first sign of cable pull. When dev_loss_tmo timer pops, terminate_rport_io is called and upper layer is about to free various resources. Terminate_rport_io trigger qla to do the final cleanup, but the cleanup might not be fast enough where it leave qla still holding on to the same resource. Wait for IO's to return to upper layer before resources are freed. Cc: [email protected] Signed-off-by: Quinn Tran <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b843add commit fc0cba0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,7 @@ static void
27502750
qla2x00_terminate_rport_io(struct fc_rport *rport)
27512751
{
27522752
fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
2753+
scsi_qla_host_t *vha;
27532754

27542755
if (!fcport)
27552756
return;
@@ -2759,9 +2760,12 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
27592760

27602761
if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
27612762
return;
2763+
vha = fcport->vha;
27622764

27632765
if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
27642766
qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
2767+
qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24,
2768+
0, WAIT_TARGET);
27652769
return;
27662770
}
27672771
/*
@@ -2786,6 +2790,15 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
27862790
qla2x00_port_logout(fcport->vha, fcport);
27872791
}
27882792
}
2793+
2794+
/* check for any straggling io left behind */
2795+
if (qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, 0, WAIT_TARGET)) {
2796+
ql_log(ql_log_warn, vha, 0x300b,
2797+
"IO not return. Resetting. \n");
2798+
set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
2799+
qla2xxx_wake_dpc(vha);
2800+
qla2x00_wait_for_chip_reset(vha);
2801+
}
27892802
}
27902803

27912804
static int

0 commit comments

Comments
 (0)