]> git.baikalelectronics.ru Git - kernel.git/commitdiff
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)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 9 Mar 2022 03:32:31 +0000 (22:32 -0500)
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>
drivers/scsi/libfc/fc_exch.c

index 841000445b9a16f31a28b94f4aa7bd2d4ad4bd7d..aa223db4cf53c0041b300d3d4e74bc98ecd9636a 100644 (file)
@@ -1701,6 +1701,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
        if (cancel_delayed_work_sync(&ep->timeout_work)) {
                FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n");
                fc_exch_release(ep);    /* release from pending timer hold */
+               return;
        }
 
        spin_lock_bh(&ep->ex_lock);