Skip to content

Commit 9ddd673

Browse files
Bart Van Asschegregkh
Bart Van Assche
authored andcommitted
libfc: Fix fc_exch_recv_req() error path
commit f6979ad upstream. Due to patch "libfc: Do not invoke the response handler after fc_exch_done()" (commit ID 7030fd6) the lport_recv() call in fc_exch_recv_req() is passed a dangling pointer. Avoid this by moving the fc_frame_free() call from fc_invoke_resp() to its callers. This patch fixes the following crash: general protection fault: 0000 [#3] PREEMPT SMP RIP: fc_lport_recv_req+0x72/0x280 [libfc] Call Trace: fc_exch_recv+0x642/0xde0 [libfc] fcoe_percpu_receive_thread+0x46a/0x5ed [fcoe] kthread+0x10a/0x120 ret_from_fork+0x42/0x70 Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Vasu Dev <[email protected]> Signed-off-by: James Bottomley <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3f52099 commit 9ddd673

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/scsi/libfc/fc_exch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,6 @@ static bool fc_invoke_resp(struct fc_exch *ep, struct fc_seq *sp,
733733
if (resp) {
734734
resp(sp, fp, arg);
735735
res = true;
736-
} else if (!IS_ERR(fp)) {
737-
fc_frame_free(fp);
738736
}
739737

740738
spin_lock_bh(&ep->ex_lock);
@@ -1596,7 +1594,8 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
15961594
* If new exch resp handler is valid then call that
15971595
* first.
15981596
*/
1599-
fc_invoke_resp(ep, sp, fp);
1597+
if (!fc_invoke_resp(ep, sp, fp))
1598+
fc_frame_free(fp);
16001599

16011600
fc_exch_release(ep);
16021601
return;
@@ -1695,7 +1694,8 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
16951694
fc_exch_hold(ep);
16961695
if (!rc)
16971696
fc_exch_delete(ep);
1698-
fc_invoke_resp(ep, sp, fp);
1697+
if (!fc_invoke_resp(ep, sp, fp))
1698+
fc_frame_free(fp);
16991699
if (has_rec)
17001700
fc_exch_timer_set(ep, ep->r_a_tov);
17011701
fc_exch_release(ep);

0 commit comments

Comments
 (0)