fs/smb/server/transport_rdma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Oct 2025 21:09:00 +0200
Add two jump targets so that a bit of exception handling can be better
reused at the end of this function implementation.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/smb/server/transport_rdma.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
index b3077766d6ec..a201c5871a77 100644
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -1574,18 +1574,14 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
get_buf_page_count(desc_buf, desc_buf_len),
msg->sg_list, SG_CHUNK_SIZE);
if (ret) {
- kfree(msg);
ret = -ENOMEM;
- goto out;
+ goto free_msg;
}
ret = get_sg_list(desc_buf, desc_buf_len,
msg->sgt.sgl, msg->sgt.orig_nents);
- if (ret < 0) {
- sg_free_table_chained(&msg->sgt, SG_CHUNK_SIZE);
- kfree(msg);
- goto out;
- }
+ if (ret < 0)
+ goto free_table;
ret = rdma_rw_ctx_init(&msg->rdma_ctx, sc->ib.qp, sc->ib.qp->port,
msg->sgt.sgl,
@@ -1596,9 +1592,7 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
is_read ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
if (ret < 0) {
pr_err("failed to init rdma_rw_ctx: %d\n", ret);
- sg_free_table_chained(&msg->sgt, SG_CHUNK_SIZE);
- kfree(msg);
- goto out;
+ goto free_table;
}
list_add_tail(&msg->list, &msg_list);
@@ -1630,6 +1624,12 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,
atomic_add(credits_needed, &sc->rw_io.credits.count);
wake_up(&sc->rw_io.credits.wait_queue);
return ret;
+
+free_table:
+ sg_free_table_chained(&msg->sgt, SG_CHUNK_SIZE);
+free_msg:
+ kfree(msg);
+ goto out;
}
static int smb_direct_rdma_write(struct ksmbd_transport *t,
--
2.51.0
Hi Markus, > Add two jump targets so that a bit of exception handling can be better > reused at the end of this function implementation. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Reviewed-by: Stefan Metzmacher <metze@samba.org> I'll add this to my for-6.19/fs-smb branch and rebase on top of it as this function will move to another file there. Namjae, Steve: this can also be pushed to 6.18 if you want. Thanks! metze
Added to ksmbd-for-next On Thu, Oct 2, 2025 at 7:31 AM Stefan Metzmacher <metze@samba.org> wrote: > > Hi Markus, > > > Add two jump targets so that a bit of exception handling can be better > > reused at the end of this function implementation. > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > Reviewed-by: Stefan Metzmacher <metze@samba.org> > > I'll add this to my for-6.19/fs-smb branch and rebase on top > of it as this function will move to another file there. > > Namjae, Steve: this can also be pushed to 6.18 if you want. > > Thanks! > metze > -- Thanks, Steve
On Thu, Oct 2, 2025 at 9:31 PM Stefan Metzmacher <metze@samba.org> wrote: > > Hi Markus, > > > Add two jump targets so that a bit of exception handling can be better > > reused at the end of this function implementation. > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > Reviewed-by: Stefan Metzmacher <metze@samba.org> > > I'll add this to my for-6.19/fs-smb branch and rebase on top > of it as this function will move to another file there. > > Namjae, Steve: this can also be pushed to 6.18 if you want. Acked-by: Namjae Jeon <linkinjeon@kernel.org> Steve, Please add this patch to #ksmbd-for-next. Thanks. > > Thanks! > metze >
© 2016 - 2026 Red Hat, Inc.