Skip to content

Commit 24eff17

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: let recv_done() avoid touching data_transfer after cleanup/move
Calling enqueue_reassembly() and wake_up_interruptible(&info->wait_reassembly_queue) or put_receive_buffer() means the response/data_transfer pointer might get re-used by another thread, which means these should be the last operations before calling return. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Fixes: f198186 ("CIFS: SMBD: Establish SMB Direct connection") Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent bdd7afc commit 24eff17

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

fs/smb/client/smbdirect.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,6 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
479479
data_transfer = smbd_response_payload(response);
480480
data_length = le32_to_cpu(data_transfer->data_length);
481481

482-
/*
483-
* If this is a packet with data playload place the data in
484-
* reassembly queue and wake up the reading thread
485-
*/
486482
if (data_length) {
487483
if (info->full_packet_received)
488484
response->first_segment = true;
@@ -491,16 +487,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
491487
info->full_packet_received = false;
492488
else
493489
info->full_packet_received = true;
494-
495-
enqueue_reassembly(
496-
info,
497-
response,
498-
data_length);
499-
} else
500-
put_receive_buffer(info, response);
501-
502-
if (data_length)
503-
wake_up_interruptible(&info->wait_reassembly_queue);
490+
}
504491

505492
atomic_dec(&info->receive_credits);
506493
info->receive_credit_target =
@@ -528,6 +515,16 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
528515
info->keep_alive_requested = KEEP_ALIVE_PENDING;
529516
}
530517

518+
/*
519+
* If this is a packet with data playload place the data in
520+
* reassembly queue and wake up the reading thread
521+
*/
522+
if (data_length) {
523+
enqueue_reassembly(info, response, data_length);
524+
wake_up_interruptible(&info->wait_reassembly_queue);
525+
} else
526+
put_receive_buffer(info, response);
527+
531528
return;
532529
}
533530

0 commit comments

Comments
 (0)