Skip to content

Commit

Permalink
io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring()
Browse files Browse the repository at this point in the history
The io_mem_alloc() function returns error pointers, not NULL.  Update
the check accordingly.

Fixes: b10b73c ("io_uring/kbuf: recycle freed mapped buffer ring entries")
Signed-off-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Dan Carpenter authored and axboe committed Dec 5, 2023
1 parent f7b32e7 commit e53f7b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions io_uring/kbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,8 @@ static int io_alloc_pbuf_ring(struct io_ring_ctx *ctx,
ibf = io_lookup_buf_free_entry(ctx, ring_size);
if (!ibf) {
ptr = io_mem_alloc(ring_size);
if (!ptr)
return -ENOMEM;
if (IS_ERR(ptr))
return PTR_ERR(ptr);

/* Allocate and store deferred free entry */
ibf = kmalloc(sizeof(*ibf), GFP_KERNEL_ACCOUNT);
Expand Down

0 comments on commit e53f7b5

Please sign in to comment.