diff options
author | Dan Carpenter <[email protected]> | 2021-02-01 15:23:42 +0300 |
---|---|---|
committer | Jens Axboe <[email protected]> | 2021-02-01 11:56:41 -0700 |
commit | 13770a71ed35512cc73c6b350297a797f0b27880 (patch) | |
tree | 187ba85ec28682e4c620221c98068498b74066ac | |
parent | 8b28fdf21193d35d6ec5a8430f0241f5f977c6ac (diff) |
io_uring: Fix NULL dereference in error in io_sqe_files_register()
If we hit a "goto out_free;" before the "ctx->file_data" pointer has
been assigned then it leads to a NULL derefence when we call:
free_fixed_rsrc_data(ctx->file_data);
We can fix this by moving the assignment earlier.
Fixes: 1ad555c6ae6e ("io_uring: create common fixed_rsrc_data allocation routines")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Pavel Begunkov <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r-- | fs/io_uring.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index a8bf867b6cf2..6711200ece22 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7865,6 +7865,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, file_data = alloc_fixed_rsrc_data(ctx); if (!file_data) return -ENOMEM; + ctx->file_data = file_data; nr_tables = DIV_ROUND_UP(nr_args, IORING_MAX_FILES_TABLE); file_data->table = kcalloc(nr_tables, sizeof(*file_data->table), @@ -7874,7 +7875,6 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, if (io_sqe_alloc_file_tables(file_data, nr_tables, nr_args)) goto out_free; - ctx->file_data = file_data; for (i = 0; i < nr_args; i++, ctx->nr_user_files++) { struct fixed_rsrc_table *table; |