Skip to content

Commit ef075c1

Browse files
isilenceSasha Levin
authored andcommitted
io_uring/zcrx: fix sgtable leak on mapping failures
[ Upstream commit a983aae ] In an unlikely case when io_populate_area_dma() fails, which could only happen on a PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA machine, io_zcrx_map_area() will have an initialised and not freed table. It was supposed to be cleaned up in the error path, but !is_mapped prevents that. Fixes: 439a98b ("io_uring/zcrx: deduplicate area mapping") Cc: stable@vger.kernel.org Reported-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 07a0de6 commit ef075c1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

io_uring/zcrx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ static int io_zcrx_map_area(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area)
288288
}
289289

290290
ret = io_populate_area_dma(ifq, area);
291+
if (ret && !area->mem.is_dmabuf)
292+
dma_unmap_sgtable(ifq->dev, &area->mem.page_sg_table,
293+
DMA_FROM_DEVICE, IO_DMA_ATTR);
291294
if (ret == 0)
292295
area->is_mapped = true;
293296
return ret;

0 commit comments

Comments
 (0)