On 11/20/19 8:58 AM, syzbot wrote: > syzbot has found a reproducer for the following crash on: > > HEAD commit: 5d1131b4 Add linux-next specific files for 20191119 > git tree: linux-next > console output: https://syzkaller.appspot.com/x/log.txt?x=140b0412e00000 > kernel config: https://syzkaller.appspot.com/x/.config?x=b60c562d89e5a8df > dashboard link: https://syzkaller.appspot.com/bug?extid=0d818c0d39399188f393 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=169b29d2e00000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14b3956ae00000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+0d818c0d39399188f393@xxxxxxxxxxxxxxxxxxxxxxxxx Thanks, the below should fix it. diff --git a/fs/io_uring.c b/fs/io_uring.c index 100931b40301..066b59ffb54e 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4568,12 +4568,18 @@ static int io_allocate_scq_urings(struct io_ring_ctx *ctx, ctx->cq_entries = rings->cq_ring_entries; size = array_size(sizeof(struct io_uring_sqe), p->sq_entries); - if (size == SIZE_MAX) + if (size == SIZE_MAX) { + io_mem_free(ctx->rings); + ctx->rings = NULL; return -EOVERFLOW; + } ctx->sq_sqes = io_mem_alloc(size); - if (!ctx->sq_sqes) + if (!ctx->sq_sqes) { + io_mem_free(ctx->rings); + ctx->rings = NULL; return -ENOMEM; + } return 0; } -- Jens Axboe