* [PATCH] erofs-utils: fix memory leak when erofs_fill_inode() fails
@ 2021-01-18 12:40 Hu Weiwen
2021-01-19 6:11 ` [PATCH v2] " Hu Weiwen
0 siblings, 1 reply; 6+ messages in thread
From: Hu Weiwen @ 2021-01-18 12:40 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: Hu Weiwen
Signeo-off-by: Hu Weiwen <sehuww@mail.scut.edu.cn>
---
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);
}
void erofs_fixup_meta_blkaddr(struct erofs_inode *rootdir)
--
2.30.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2] erofs-utils: fix memory leak when erofs_fill_inode() fails
2021-01-18 12:40 [PATCH] erofs-utils: fix memory leak when erofs_fill_inode() fails Hu Weiwen
@ 2021-01-19 6:11 ` Hu Weiwen
2021-01-19 15:36 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Hu Weiwen @ 2021-01-19 6:11 UTC (permalink / raw)
To: sehuww; +Cc: linux-erofs
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);
}
void erofs_fixup_meta_blkaddr(struct erofs_inode *rootdir)
--
2.30.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] erofs-utils: fix memory leak when erofs_fill_inode() fails
2021-01-19 6:11 ` [PATCH v2] " Hu Weiwen
@ 2021-01-19 15:36 ` Gao Xiang
2021-01-21 16:21 ` [PATCH v3] " Hu Weiwen
0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2021-01-19 15:36 UTC (permalink / raw)
To: Hu Weiwen; +Cc: linux-erofs
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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] erofs-utils: fix memory leak when erofs_fill_inode() fails
2021-01-19 15:36 ` Gao Xiang
@ 2021-01-21 16:21 ` Hu Weiwen
2021-01-22 2:00 ` Gao Xiang
2021-02-06 14:04 ` Li GuiFu via Linux-erofs
0 siblings, 2 replies; 6+ messages in thread
From: Hu Weiwen @ 2021-01-21 16:21 UTC (permalink / raw)
To: hsiangkao; +Cc: linux-erofs
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] erofs-utils: fix memory leak when erofs_fill_inode() fails
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
1 sibling, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2021-01-22 2:00 UTC (permalink / raw)
To: Hu Weiwen; +Cc: linux-erofs
On Fri, Jan 22, 2021 at 12:21:01AM +0800, Hu Weiwen wrote:
> Signed-off-by: Hu Weiwen <sehuww@mail.scut.edu.cn>
Reviewed-by: Gao Xiang <hsiangkao@aol.com>
Thanks,
Gao Xiang
> ---
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] erofs-utils: fix memory leak when erofs_fill_inode() fails
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
1 sibling, 0 replies; 6+ messages in thread
From: Li GuiFu via Linux-erofs @ 2021-02-06 14:04 UTC (permalink / raw)
To: Hu Weiwen, hsiangkao; +Cc: linux-erofs
On 2021/1/22 0:21, Hu Weiwen wrote:
> Signed-off-by: Hu Weiwen <sehuww@mail.scut.edu.cn>
> ---
> lib/inode.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
It looks good
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-02-06 14:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v3] " Hu Weiwen
2021-01-22 2:00 ` Gao Xiang
2021-02-06 14:04 ` Li GuiFu via Linux-erofs
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).