Re: [PATCH] io_uring: fix file leak on creating io ctx

From: Jens Axboe
Date: Mon Dec 07 2020 - 11:43:05 EST


On 12/7/20 1:15 AM, Hillf Danton wrote:
> @@ -9207,12 +9208,14 @@ err_fd:
> #if defined(CONFIG_UNIX)
> ctx->ring_sock->file = file;
> #endif
> - if (unlikely(io_uring_add_task_file(ctx, file))) {
> - file = ERR_PTR(-ENOMEM);
> - goto err_fd;
> + ret = io_uring_add_task_file(ctx, file);
> + if (ret) {
> + fput(file);
> + put_unused_fd(fd);
> + goto err;
> }
> fd_install(ret, file);
> - return ret;
> + return 0;

You're installing the return value from io_uring_add_task_file() in the
fd table, and then returning '0' for the fd...

--
Jens Axboe