scsi: libfc: Fix use after free in fc_exch_abts_resp()
authorJianglei Nie <niejianglei2021@163.com>
Thu, 3 Mar 2022 01:51:15 +0000 (09:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 19:00:59 +0000 (21:00 +0200)
commit1d7effe5fff9d28e45e18ac3a564067c7ddfe898
tree6022d95ef296aee912eb527b8568fc85dc967004
parent02222bf4f0a27f6eba66d1f597cdb5daadd51829
scsi: libfc: Fix use after free in fc_exch_abts_resp()

[ Upstream commit 271add11994ba1a334859069367e04d2be2ebdd4 ]

fc_exch_release(ep) will decrease the ep's reference count. When the
reference count reaches zero, it is freed. But ep is still used in the
following code, which will lead to a use after free.

Return after the fc_exch_release() call to avoid use after free.

Link: https://lore.kernel.org/r/20220303015115.459778-1-niejianglei2021@163.com
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/libfc/fc_exch.c