linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Hu Weiwen <sehuww@mail.scut.edu.cn>
To: hsiangkao@redhat.com
Cc: linux-erofs@lists.ozlabs.org
Subject: [PATCH v3] erofs-utils: fix memory leak when erofs_fill_inode() fails
Date: Fri, 22 Jan 2021 00:21:01 +0800	[thread overview]
Message-ID: <20210121162101.7093-1-sehuww@mail.scut.edu.cn> (raw)
In-Reply-To: <20210119153620.GA2601261@xiangao.remote.csb>

Signed-off-by: Hu Weiwen <sehuww@mail.scut.edu.cn>
---
 lib/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/inode.c b/lib/inode.c
index d6a64cc..73a7e69 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -867,8 +867,10 @@ struct erofs_inode *erofs_iget_from_path(const char *path, bool is_src)
 		return inode;
 
 	ret = erofs_fill_inode(inode, &st, path);
-	if (ret)
+	if (ret) {
+		free(inode);
 		return ERR_PTR(ret);
+	}
 
 	return inode;
 }
-- 
2.30.0


  reply	other threads:[~2021-01-21 16:22 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
2021-01-21 16:21     ` Hu Weiwen [this message]
2021-01-22  2:00       ` [PATCH v3] " 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=20210121162101.7093-1-sehuww@mail.scut.edu.cn \
    --to=sehuww@mail.scut.edu.cn \
    --cc=hsiangkao@redhat.com \
    --cc=linux-erofs@lists.ozlabs.org \
    /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).