Skip to content

Commit af6de8c

Browse files
Ewan D. Milnemartinkpetersen
authored andcommitted
scsi: lpfc: nvmet: Avoid hang / use-after-free again when destroying targetport
We cannot wait on a completion object in the lpfc_nvme_targetport structure in the _destroy_targetport() code path because the NVMe/fc transport will free that structure immediately after the .targetport_delete() callback. This results in a use-after-free, and a crash if slub_debug=FZPU is enabled. An earlier fix put put the completion on the stack, but commit 2a0fb34 ("scsi: lpfc: Correct localport timeout duration error") subsequently changed the code to reference the completion through a pointer in the object rather than the local stack variable. Fix this by using the stack variable directly. Link: https://lore.kernel.org/r/[email protected] Fixes: 2a0fb34 ("scsi: lpfc: Correct localport timeout duration error") Reviewed-by: James Smart <[email protected]> Signed-off-by: Ewan D. Milne <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 8a8fb89 commit af6de8c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/lpfc/lpfc_nvmet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba)
21102110
}
21112111
tgtp->tport_unreg_cmp = &tport_unreg_cmp;
21122112
nvmet_fc_unregister_targetport(phba->targetport);
2113-
if (!wait_for_completion_timeout(tgtp->tport_unreg_cmp,
2113+
if (!wait_for_completion_timeout(&tport_unreg_cmp,
21142114
msecs_to_jiffies(LPFC_NVMET_WAIT_TMO)))
21152115
lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
21162116
"6179 Unreg targetport x%px timeout "

0 commit comments

Comments
 (0)