]> www.infradead.org Git - users/hch/misc.git/commitdiff
smb: client: let destroy_mr_list() call ib_dereg_mr() before ib_dma_unmap_sg()
authorStefan Metzmacher <metze@samba.org>
Sun, 12 Oct 2025 19:10:29 +0000 (21:10 +0200)
committerSteve French <stfrench@microsoft.com>
Mon, 13 Oct 2025 13:26:22 +0000 (08:26 -0500)
This is more consistent as we call ib_dma_unmap_sg() only
when the memory is no longer registered.

This is the same pattern as calling ib_dma_unmap_sg() after
IB_WR_LOCAL_INV.

Fixes: c7398583340a ("CIFS: SMBD: Implement RDMA memory registration")
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smbdirect.c

index 21dcd326af3df4d28f0bd0d0515690200a3a1542..c3330e43488fc5063d4468f2b270821f6e6c1714 100644 (file)
@@ -2365,9 +2365,10 @@ static void destroy_mr_list(struct smbdirect_socket *sc)
        spin_unlock_irqrestore(&sc->mr_io.all.lock, flags);
 
        list_for_each_entry_safe(mr, tmp, &all_list, list) {
+               if (mr->mr)
+                       ib_dereg_mr(mr->mr);
                if (mr->sgt.nents)
                        ib_dma_unmap_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir);
-               ib_dereg_mr(mr->mr);
                kfree(mr->sgt.sgl);
                list_del(&mr->list);
                kfree(mr);