Re: [PATCH v1] io_uring: Fix memory leak if file setup fails.

From: Noah Goldstein
Date: Fri Apr 29 2022 - 11:37:13 EST


On Fri, Apr 29, 2022 at 7:47 AM Jens Axboe <axboe@xxxxxxxxx> wrote:
>
> On 4/28/22 6:42 PM, Noah Goldstein wrote:
> > If `get_unused_fd_flags` files fails (either in setting up `ctx` as
> > `tctx->last` or `get_unused_fd_flags`) `ctx` will never be freed.
>
> There's a comment there telling you why, the fput will end up
> releasing it just like it would when an application closes it.

I see. Thought the 'it' refered to in the comment was the file, not
ctx.

>
> > I very well may be missing something (or there may be a double
> > free if the failure is after `get_unused_fd_flags`) but looks
> > to me to be a memory leak.
>
> Have you tried synthetically reproducing the two failures you're
> thinking of and tracing cleanup?
>
> --
> Jens Axboe
>