Re: [PATCH] loop: fix backing file reference leak on validation error

From: Li Chen

Date: Mon Sep 29 2025 - 20:05:44 EST


Hi Ming,

---- On Mon, 29 Sep 2025 23:01:50 +0800 Ming Lei <ming.lei@xxxxxxxxxx> wrote ---
> On Mon, Sep 29, 2025 at 8:54 PM Li Chen <me@linux.beauty> wrote:
> >
> > Hi Markus,
> >
> > ---- On Sun, 28 Sep 2025 21:48:23 +0800 Markus Elfring <Markus.Elfring@xxxxxx> wrote ---
> > > …
> > > > Fix this by calling fput(file) before returning the error.
> > > …
> > > > +++ b/drivers/block/loop.c
> > > …
> > >
> > > How do you think about to increase the application of scope-based resource management?
> > > https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/file.h#L97
> >
> > Looks good; I will add a commit to switch to scope-based resource management in v2.
> > Thanks for your suggestion!
>
> Please don't do it as one bug fix, the whole fix chain needs to
> backport, and scope-based
> fput is just added in v6.15.
>
> However, you can do it as one cleanup after the fix is merged.

Noted, thanks for your tip.

Regards,
Li