<div dir="ltr"><p class="gmail-font-claude-response-body gmail-break-words gmail-whitespace-normal gmail-leading-[1.7]">Hi Utkal,</p>
<p class="gmail-font-claude-response-body gmail-break-words gmail-whitespace-pre-wrap gmail-leading-[1.7]">Thanks for the review. You're right on both points — v2 will use
erofs_io_close() and fix the indentation.</p>
<p class="gmail-font-claude-response-body gmail-break-words gmail-whitespace-pre-wrap gmail-leading-[1.7]">Thanks,
Deepak Pathik</p></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Apr 2, 2026 at 9:58 AM Utkal Singh <<a href="mailto:singhutkal015@gmail.com">singhutkal015@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 02 Apr 2026 01:10, Deepak Pathik wrote:<br>
> +if (!m2gr->bmgr) {<br>
> +close(m2gr->vf.fd);<br>
<br>
erofs_io_close() does more than close(fd) — it dispatches through<br>
vf->ops->close(vf) if ops is set, and resets vf->fd to -1 afterward.<br>
Using raw close() here skips both, which is incorrect.<br>
<br>
Also, the if block is missing tab indentation.<br>
<br>
Suggested fix:<br>
<br>
if (!m2gr->bmgr) {<br>
erofs_io_close(&m2gr->vf);<br>
return -ENOMEM;<br>
}<br>
<br>
On Thu, 2 Apr 2026 at 01:10, Deepak Pathik <<a href="mailto:deepakpathik2005@gmail.com" target="_blank">deepakpathik2005@gmail.com</a>> wrote:<br>
><br>
> In erofs_metamgr_init(), erofs_tmpfile() returns a file<br>
> descriptor stored in m2gr->vf.fd. If the subsequent<br>
> erofs_buffer_init() call fails, the function returns -ENOMEM<br>
> without closing this file descriptor.<br>
><br>
> The caller erofs_metadata_init() handles this failure at<br>
> err_free, which only frees the m2gr struct. The fd is<br>
> therefore leaked with no remaining reference to close it.<br>
><br>
> The success path correctly cleans up via erofs_metamgr_exit(),<br>
> which calls erofs_io_close(&m2gr->vf). Mirror that behaviour<br>
> on the error path by closing the fd before returning.<br>
><br>
> Signed-off-by: Deepak Pathik <<a href="mailto:deepakpathik2005@gmail.com" target="_blank">deepakpathik2005@gmail.com</a>><br>
> ---<br>
>  lib/metabox.c | 4 +++-<br>
>  1 file changed, 3 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/lib/metabox.c b/lib/metabox.c<br>
> index 12706aa..d55e787 100644<br>
> --- a/lib/metabox.c<br>
> +++ b/lib/metabox.c<br>
> @@ -32,8 +32,10 @@ static int erofs_metamgr_init(struct erofs_sb_info *sbi,<br>
><br>
>  m2gr->vf = (struct erofs_vfile){ .fd = ret };<br>
>         m2gr->bmgr = erofs_buffer_init(sbi, 0, &m2gr->vf);<br>
> - if (!m2gr->bmgr)<br>
> +if (!m2gr->bmgr) {<br>
> +close(m2gr->vf.fd);<br>
>                 return -ENOMEM;<br>
> +}<br>
>         return 0;<br>
>  }<br>
> --<br>
> 2.50.1<br>
><br>
><br>
><br>
</blockquote></div>