]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: lpfc: Prevent NDLP reference count underflow in dev_loss_tmo callback
authorJustin Tee <justin.tee@broadcom.com>
Thu, 31 Oct 2024 22:32:15 +0000 (15:32 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:04:00 +0000 (20:04 +0100)
commite4913d4bc59227fbdfe6b8f5541f49aaea1cb41c
tree030833c3d029c72fcd63f59e310e6622f9c8cb5d
parent32a2d387822b41ef5ca415167c0d76d1a6df2b65
scsi: lpfc: Prevent NDLP reference count underflow in dev_loss_tmo callback

[ Upstream commit 4281f44ea8bfedd25938a0031bebba1473ece9ad ]

Current dev_loss_tmo handling checks whether there has been a previous
call to unregister with SCSI transport.  If so, the NDLP kref count is
decremented a second time in dev_loss_tmo as the final kref release.
However, this can sometimes result in a reference count underflow if
there is also a race to unregister with NVMe transport as well.  Add a
check for NVMe transport registration before decrementing the final
kref.  If NVMe transport is still registered, then the NVMe transport
unregistration is designated as the final kref decrement.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20241031223219.152342-8-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/lpfc/lpfc_hbadisc.c