io_uring: fix resource leak in io_import_dmabuf()
authorPenglei Jiang <superman.xpt@gmail.com>
Wed, 25 Jun 2025 10:27:03 +0000 (03:27 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 25 Jun 2025 14:14:14 +0000 (08:14 -0600)
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>
Link: https://lore.kernel.org/r/20250625102703.68336-1-superman.xpt@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/zcrx.c

index 21c816c3bfe07e7bbf0f7088f9abada7ddccc943..ade4da9c4e313e2bc0b3206b7668dd44bb43353a 100644 (file)
@@ -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;