io_uring/rsrc: don't put/free empty buffers

If cloning of buffers fail and we have to put the ones already grabbed,
check for NULL buffers and skip those. They used to be dummy ubufs, but
now they are just NULL and that should be checked before reaping them.

Reported-by: chase xd <sl1589472800@gmail.com>
Link: https://lore.kernel.org/io-uring/CADZouDQ7TcKn8gz8_efnyAEp1JvU1ktRk8PWz-tO0FXUoh8VGQ@mail.gmail.com/
Fixes: d50f94d761 ("io_uring/rsrc: get rid of the empty node and dummy_ubuf")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jens Axboe 2024-12-12 08:01:52 -07:00
parent a07d2d7930
commit 99d6af6e8a

View File

@ -1036,9 +1036,11 @@ static int io_clone_buffers(struct io_ring_ctx *ctx, struct io_ring_ctx *src_ctx
out_put_free: out_put_free:
i = data.nr; i = data.nr;
while (i--) { while (i--) {
if (data.nodes[i]) {
io_buffer_unmap(src_ctx, data.nodes[i]); io_buffer_unmap(src_ctx, data.nodes[i]);
kfree(data.nodes[i]); kfree(data.nodes[i]);
} }
}
out_unlock: out_unlock:
io_rsrc_data_free(ctx, &data); io_rsrc_data_free(ctx, &data);
mutex_unlock(&src_ctx->uring_lock); mutex_unlock(&src_ctx->uring_lock);