RISCV: config: tizen_visionfive2: Enable USB_DUMMY_HCD as module for usb hcd tetst
[platform/kernel/linux-starfive.git] / io_uring / kbuf.c
index e2c4688..acc37e5 100644 (file)
@@ -228,17 +228,18 @@ static int __io_remove_buffers(struct io_ring_ctx *ctx,
                return i;
        }
 
-       /* the head kbuf is the list itself */
+       /* protects io_buffers_cache */
+       lockdep_assert_held(&ctx->uring_lock);
+
        while (!list_empty(&bl->buf_list)) {
                struct io_buffer *nxt;
 
                nxt = list_first_entry(&bl->buf_list, struct io_buffer, list);
-               list_del(&nxt->list);
+               list_move(&nxt->list, &ctx->io_buffers_cache);
                if (++i == nbufs)
                        return i;
                cond_resched();
        }
-       i++;
 
        return i;
 }
@@ -509,7 +510,7 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
        }
 
        pages = io_pin_pages(reg.ring_addr,
-                            struct_size(br, bufs, reg.ring_entries),
+                            flex_array_size(br, bufs, reg.ring_entries),
                             &nr_pages);
        if (IS_ERR(pages)) {
                kfree(free_bl);