]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smbdirect: Fix error cleanup in smbdirect_map_sges_from_iter()
authorDavid Howells <dhowells@redhat.com>
Wed, 13 May 2026 18:50:02 +0000 (19:50 +0100)
committerSteve French <stfrench@microsoft.com>
Thu, 14 May 2026 18:21:00 +0000 (13:21 -0500)
Fix smbdirect_map_sges_from_iter() to use pre-decrement, not post-decrement
so that it cleans up the correct slots.

Fixes: e5fbdde43017 ("cifs: Add a function to build an RDMA SGE list from an iterator")
Closes: https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
cc: Paulo Alcantara <pc@manguebit.org>
cc: Tom Talpey <tom@talpey.com>
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/smbdirect/connection.c

index fe9912e53da69b3f21bd42a3bf4653699e5defea..8adf580975344b698c7a0182a550e03f660cd518 100644 (file)
@@ -2168,7 +2168,7 @@ static ssize_t smbdirect_map_sges_from_iter(struct iov_iter *iter, size_t len,
 
        if (ret < 0) {
                while (state->num_sge > before) {
-                       struct ib_sge *sge = &state->sge[state->num_sge--];
+                       struct ib_sge *sge = &state->sge[--state->num_sge];
 
                        ib_dma_unmap_page(state->device,
                                          sge->addr,