Re: [PATCH] loop: fix backing file reference leak on validation error
From: Ming Lei
Date: Mon Sep 29 2025 - 01:14:27 EST
On Fri, Sep 26, 2025 at 8:13 PM Li Chen <me@linux.beauty> wrote:
>
> loop_change_fd() and loop_configure() call loop_check_backing_file()
> to validate the new backing file. If validation fails, the reference
> acquired by fget() was not dropped, leaking a file reference.
>
> Fix this by calling fput(file) before returning the error.
>
> Signed-off-by: Li Chen <chenl311@xxxxxxxxxxxxxxx>
Good catch:
Fixes: f5c84eff634b ("loop: Add sanity check for read/write_iter")
Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>
Thanks,