linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@redhat.com>
To: Hu Weiwen <sehuww@mail.scut.edu.cn>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH v2] erofs-utils: fix memory leak when erofs_fill_inode() fails
Date: Tue, 19 Jan 2021 23:36:20 +0800	[thread overview]
Message-ID: <20210119153620.GA2601261@xiangao.remote.csb> (raw)
In-Reply-To: <20210119061123.9774-1-sehuww@mail.scut.edu.cn>

Hi Weiwen,

On Tue, Jan 19, 2021 at 02:11:23PM +0800, Hu Weiwen wrote:
> Signed-off-by: Hu Weiwen <sehuww@mail.scut.edu.cn>
> ---
> fixes a typo in v1
> 
>  lib/inode.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/inode.c b/lib/inode.c
> index d6a64cc..6f6e984 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -868,9 +868,13 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
> 
>  	ret = erofs_fill_inode(inode, &st, path);
>  	if (ret)
> -		return ERR_PTR(ret);
> +		goto err;
> 
>  	return inode;
> +
> +err:
> +	free(inode);
> +	return ERR_PTR(ret);

Yeah, I think many error paths now might have memory leak, yet I'm not sure
if these does matter since the program would be exited soon... (since liberofs
doesn't export as a public library for now since I don't think these APIs are
finalized to public...)

Since there is the only one user of this label... So I think we might inline
such error path until more users exist?

Otherwise it looks good to me.

Thanks,
Gao Xiang

>  }
> 
>  void erofs_fixup_meta_blkaddr(struct erofs_inode *rootdir)
> --
> 2.30.0
> 


  reply	other threads:[~2021-01-19 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-18 12:40 [PATCH] erofs-utils: fix memory leak when erofs_fill_inode() fails Hu Weiwen
2021-01-19  6:11 ` [PATCH v2] " Hu Weiwen
2021-01-19 15:36   ` Gao Xiang [this message]
2021-01-21 16:21     ` [PATCH v3] " Hu Weiwen
2021-01-22  2:00       ` Gao Xiang
2021-02-06 14:04       ` Li GuiFu via Linux-erofs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210119153620.GA2601261@xiangao.remote.csb \
    --to=hsiangkao@redhat.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=sehuww@mail.scut.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).