public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix resource leak in io_import_dmabuf()
@ 2025-06-25 10:27 Penglei Jiang
  2025-06-25 14:52 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Penglei Jiang @ 2025-06-25 10:27 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, linux-kernel, asml.silence, Penglei Jiang

Replace the return statement with setting ret = -EINVAL and jumping to
the err label to ensure resources are released via io_release_dmabuf.

Fixes: a5c98e942457 ("io_uring/zcrx: dmabuf backed zerocopy receive")
Signed-off-by: Penglei Jiang <superman.xpt@gmail.com>
---
 io_uring/zcrx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 797247a34cb7..085eeed8cd50 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -106,8 +106,10 @@ static int io_import_dmabuf(struct io_zcrx_ifq *ifq,
 	for_each_sgtable_dma_sg(mem->sgt, sg, i)
 		total_size += sg_dma_len(sg);
 
-	if (total_size < off + len)
-		return -EINVAL;
+	if (total_size < off + len) {
+		ret = -EINVAL;
+		goto err;
+	}
 
 	mem->dmabuf_offset = off;
 	mem->size = len;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io_uring: fix resource leak in io_import_dmabuf()
  2025-06-25 10:27 [PATCH] io_uring: fix resource leak in io_import_dmabuf() Penglei Jiang
@ 2025-06-25 14:52 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2025-06-25 14:52 UTC (permalink / raw)
  To: Penglei Jiang; +Cc: io-uring, linux-kernel, asml.silence


On Wed, 25 Jun 2025 03:27:03 -0700, Penglei Jiang wrote:
> Replace the return statement with setting ret = -EINVAL and jumping to
> the err label to ensure resources are released via io_release_dmabuf.
> 
> 

Applied, thanks!

[1/1] io_uring: fix resource leak in io_import_dmabuf()
      commit: 7cac633a42a7b3c8146eb1db76fb80dc652998de

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-25 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 10:27 [PATCH] io_uring: fix resource leak in io_import_dmabuf() Penglei Jiang
2025-06-25 14:52 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox