smb: server: Use common error handling code in smb_direct_rdma_xmit()
Subsystems (4)
PATCH 1/1 smb: server: Use common error handling code in smb_direct_rdma_xmit()
From: Markus Elfring <[email protected]>
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.
--- fs/smb/server/transport_rdma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
fs/smb/server/transport_rdma.c +10 -10
@@ -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,
Signature · 1 line
2.51.0
Hi Markus,
Quoted 4 lines
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 <[email protected]>
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
Quoted 6 lines · Stefan Metzmacher
Hi Markus,
Quoted 3 lines
Add two jump targets so that a bit of exception handling can be better reused at the end of this function implementation.
Quoted 8 lines
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>Reviewed-by Stefan Metzmacher <[email protected]>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.
Steve, Please add this patch to #ksmbd-for-next.
Thanks.
Quoted 4 lines
Thanks!
metze
Added to ksmbd-for-next
Quoted 18 lines · Stefan Metzmacher
Hi Markus,
Quoted 4 lines
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 <[email protected]>Reviewed-by Stefan Metzmacher <[email protected]>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
Signature · 3 lines
Thanks, Steve