]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smb: client: let send_done() cleanup before calling smbd_disconnect_rdma_connection()
authorStefan Metzmacher <metze@samba.org>
Mon, 4 Aug 2025 12:10:12 +0000 (14:10 +0200)
committerSteve French <stfrench@microsoft.com>
Wed, 6 Aug 2025 20:04:13 +0000 (15:04 -0500)
We should call ib_dma_unmap_single() and mempool_free() before calling
smbd_disconnect_rdma_connection().

And smbd_disconnect_rdma_connection() needs to be the last function to
call as all other state might already be gone after it returns.

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: f198186aa9bb ("CIFS: SMBD: Establish SMB Direct connection")
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smbdirect.c

index 754e94a0e07f502d70bb24fa06b4b8762be44a8b..e99e783f1b0e1cda60a6149f3999093711ceadc8 100644 (file)
@@ -281,18 +281,20 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
        log_rdma_send(INFO, "smbd_request 0x%p completed wc->status=%d\n",
                request, wc->status);
 
-       if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_SEND) {
-               log_rdma_send(ERR, "wc->status=%d wc->opcode=%d\n",
-                       wc->status, wc->opcode);
-               smbd_disconnect_rdma_connection(request->info);
-       }
-
        for (i = 0; i < request->num_sge; i++)
                ib_dma_unmap_single(sc->ib.dev,
                        request->sge[i].addr,
                        request->sge[i].length,
                        DMA_TO_DEVICE);
 
+       if (wc->status != IB_WC_SUCCESS || wc->opcode != IB_WC_SEND) {
+               log_rdma_send(ERR, "wc->status=%d wc->opcode=%d\n",
+                       wc->status, wc->opcode);
+               mempool_free(request, info->request_mempool);
+               smbd_disconnect_rdma_connection(info);
+               return;
+       }
+
        if (atomic_dec_and_test(&request->info->send_pending))
                wake_up(&request->info->wait_send_pending);