Skip to content

Commit 720df23

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: fix null ifq on area destruction
Dan reports that ifq can be null when infering arguments for io_unaccount_mem() from io_zcrx_free_area(). Fix it by always setting a correct ifq. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Fixes: 262ab20 ("io_uring/zcrx: account area memory") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/20670d163bb90dba2a81a4150f1125603cefb101.1753091564.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent d1fbe1e commit 720df23

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

io_uring/zcrx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ static void io_free_rbuf_ring(struct io_zcrx_ifq *ifq)
377377

378378
static void io_zcrx_free_area(struct io_zcrx_area *area)
379379
{
380-
if (area->ifq)
381-
io_zcrx_unmap_area(area->ifq, area);
380+
io_zcrx_unmap_area(area->ifq, area);
382381
io_release_area_mem(&area->mem);
383382

384383
if (area->mem.account_pages)
@@ -411,6 +410,7 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
411410
area = kzalloc(sizeof(*area), GFP_KERNEL);
412411
if (!area)
413412
goto err;
413+
area->ifq = ifq;
414414

415415
ret = io_import_area(ifq, &area->mem, area_reg);
416416
if (ret)
@@ -445,7 +445,6 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
445445
}
446446

447447
area->free_count = nr_iovs;
448-
area->ifq = ifq;
449448
/* we're only supporting one area per ifq for now */
450449
area->area_id = 0;
451450
area_reg->rq_area_token = (u64)area->area_id << IORING_ZCRX_AREA_SHIFT;

0 commit comments

Comments
 (0)