Skip to content

Commit e004d86

Browse files
isilencegregkh
authored andcommitted
io_uring/zcrx: fix null ifq on area destruction
commit 720df23 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6461965 commit e004d86

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
@@ -394,8 +394,7 @@ static void io_free_rbuf_ring(struct io_zcrx_ifq *ifq)
394394

395395
static void io_zcrx_free_area(struct io_zcrx_area *area)
396396
{
397-
if (area->ifq)
398-
io_zcrx_unmap_area(area->ifq, area);
397+
io_zcrx_unmap_area(area->ifq, area);
399398
io_release_area_mem(&area->mem);
400399

401400
if (area->mem.account_pages)
@@ -428,6 +427,7 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
428427
area = kzalloc(sizeof(*area), GFP_KERNEL);
429428
if (!area)
430429
goto err;
430+
area->ifq = ifq;
431431

432432
ret = io_import_area(ifq, &area->mem, area_reg);
433433
if (ret)
@@ -462,7 +462,6 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
462462
}
463463

464464
area->free_count = nr_iovs;
465-
area->ifq = ifq;
466465
/* we're only supporting one area per ifq for now */
467466
area->area_id = 0;
468467
area_reg->rq_area_token = (u64)area->area_id << IORING_ZCRX_AREA_SHIFT;

0 commit comments

Comments
 (0)