scsi: lpfc: nvmet: avoid hang / use-after-free when destroying targetport
authorEwan D. Milne <emilne@redhat.com>
Thu, 17 Jan 2019 16:14:45 +0000 (11:14 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Mar 2019 16:58:50 +0000 (17:58 +0100)
commitee2a02a66821d76a5625162144afc82384c24706
tree335adc3546e3f87a977436e910a9d4c7cf7bf33f
parent30b62656690d76bb6a033db9ed88d7bf81180e42
scsi: lpfc: nvmet: avoid hang / use-after-free when destroying targetport

[ Upstream commit c41f59884be5cca293ed61f3d64637dbba3a6381 ]

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 hang if slub_debug=FZPU is enabled.

Fix this by putting the completion on the stack.

Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/lpfc/lpfc_nvmet.c
drivers/scsi/lpfc/lpfc_nvmet.h