]> git.itanic.dy.fi Git - linux-stable/commitdiff
io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring()
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 5 Dec 2023 12:37:17 +0000 (15:37 +0300)
committerJens Axboe <axboe@kernel.dk>
Tue, 5 Dec 2023 13:59:56 +0000 (06:59 -0700)
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@linaro.org>
Link: https://lore.kernel.org/r/5ed268d3-a997-4f64-bd71-47faa92101ab@moroto.mountain
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/kbuf.c

index 268788305b612cf3e8c2670ad5ac3bd71110fd9f..bd25bc2deeaf837bc3f34ec69984722ea7b39052 100644 (file)
@@ -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);