]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: elx: libefc: Fix potential use after free in efc_nport_vport_del()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 15 Aug 2024 11:29:05 +0000 (14:29 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:32:44 +0000 (16:32 +0200)
commit7c2908985e4ae0ea1b526b3916de9e5351650908
tree74a545cbd6256fccf74114f9e2b75032dddd54bc
parent5da620c8654522c2dfd5269748f54fd98f8364e3
scsi: elx: libefc: Fix potential use after free in efc_nport_vport_del()

[ Upstream commit 2e4b02fad094976763af08fec2c620f4f8edd9ae ]

The kref_put() function will call nport->release if the refcount drops to
zero.  The nport->release release function is _efc_nport_free() which frees
"nport".  But then we dereference "nport" on the next line which is a use
after free.  Re-order these lines to avoid the use after free.

Fixes: fcd427303eb9 ("scsi: elx: libefc: SLI and FC PORT state machine interfaces")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/b666ab26-6581-4213-9a3d-32a9147f0399@stanley.mountain
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/elx/libefc/efc_nport.c