This is a note to let you know that I've just added the patch titled io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring() to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-kbuf-fix-an-null-vs-is_err-bug-in-io_alloc_.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 2d39d07ccd2bc8d76207a57b0e4faaa479aa77c6 Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Date: Tue Dec 5 15:37:17 2023 +0300 io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring() [ Upstream commit e53f7b54b1fdecae897f25002ff0cff04faab228 ] The io_mem_alloc() function returns error pointers, not NULL. Update the check accordingly. Fixes: b10b73c102a2 ("io_uring/kbuf: recycle freed mapped buffer ring entries") Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Link: https://lore.kernel.org/r/5ed268d3-a997-4f64-bd71-47faa92101ab@moroto.mountain Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index 012f622036049..12eec4778c5b1 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -623,8 +623,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);