Re: [PATCH] loop: fix backing file reference leak on validation error
From: Ming Lei
Date: Mon Sep 29 2025 - 11:02:16 EST
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.
Thanks,