diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c index 8914869ed29a..ceca13de070f 100644 --- a/io_uring/zcrx.c +++ b/io_uring/zcrx.c @@ -121,21 +121,25 @@ static int io_populate_area_dma(struct io_zcrx_ifq *ifq, return 0; } -static void io_release_dmabuf(struct io_zcrx_mem *mem) +static void io_unmap_dmabuf(struct io_zcrx_mem *mem) { if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER)) return; - if (mem->sgt) dma_buf_unmap_attachment_unlocked(mem->attach, mem->sgt, DMA_FROM_DEVICE); if (mem->attach) dma_buf_detach(mem->dmabuf, mem->attach); - if (mem->dmabuf) - dma_buf_put(mem->dmabuf); - mem->sgt = NULL; mem->attach = NULL; +} + +static void io_release_dmabuf(struct io_zcrx_mem *mem) +{ + if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER)) + return; + if (mem->dmabuf) + dma_buf_put(mem->dmabuf); mem->dmabuf = NULL; } @@ -190,6 +194,7 @@ static int io_import_dmabuf(struct io_zcrx_ifq *ifq, mem->size = len; return 0; err: + io_unmap_dmabuf(mem); io_release_dmabuf(mem); return ret; } @@ -317,7 +322,7 @@ static void io_zcrx_unmap_area(struct io_zcrx_ifq *ifq, } if (area->mem.is_dmabuf) { - io_release_dmabuf(&area->mem); + io_unmap_dmabuf(&area->mem); } else { dma_unmap_sgtable(ifq->dev, &area->mem.page_sg_table, DMA_FROM_DEVICE, IO_DMA_ATTR);