* [PATCH] erofs-utils: check the return value of erofs_d_alloc
@ 2021-11-17 10:21 Huang Jianan via Linux-erofs
2021-11-17 10:21 ` [PATCH] erofs-utils: fix memory leak when get blob chunk Huang Jianan via Linux-erofs
2021-11-18 10:04 ` [PATCH] erofs-utils: check the return value of erofs_d_alloc Yue Hu
0 siblings, 2 replies; 3+ messages in thread
From: Huang Jianan via Linux-erofs @ 2021-11-17 10:21 UTC (permalink / raw)
To: linux-erofs, xiang; +Cc: yh, guoweichao, zhangshiming, guanyuwei
Need to check whether the allocation of erofs_dentry is successful.
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
---
lib/inode.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/inode.c b/lib/inode.c
index 5cbfc78..2fa74e2 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -162,11 +162,15 @@ int erofs_prepare_dir_file(struct erofs_inode *dir, unsigned int nr_subdirs)
/* dot is pointed to the current dir inode */
d = erofs_d_alloc(dir, ".");
+ if (IS_ERR(d))
+ return PTR_ERR(d);
d->inode = erofs_igrab(dir);
d->type = EROFS_FT_DIR;
/* dotdot is pointed to the parent dir */
d = erofs_d_alloc(dir, "..");
+ if (IS_ERR(d))
+ return PTR_ERR(d);
d->inode = erofs_igrab(dir->i_parent);
d->type = EROFS_FT_DIR;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] erofs-utils: fix memory leak when get blob chunk
2021-11-17 10:21 [PATCH] erofs-utils: check the return value of erofs_d_alloc Huang Jianan via Linux-erofs
@ 2021-11-17 10:21 ` Huang Jianan via Linux-erofs
2021-11-18 10:04 ` [PATCH] erofs-utils: check the return value of erofs_d_alloc Yue Hu
1 sibling, 0 replies; 3+ messages in thread
From: Huang Jianan via Linux-erofs @ 2021-11-17 10:21 UTC (permalink / raw)
To: linux-erofs, xiang; +Cc: yh, guoweichao, zhangshiming, guanyuwei
Release memory allocated for chunk before return error.
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
---
lib/blobchunk.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index 5cbb831..b605b0b 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -78,6 +78,7 @@ static struct erofs_blobchunk *erofs_blob_getchunk(int fd,
hashmap_entry_init(&key, hash);
hashmap_remove(&blob_hashmap, &key, sha256);
+ free(chunk);
chunk = ERR_PTR(-ENOSPC);
goto out;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs-utils: check the return value of erofs_d_alloc
2021-11-17 10:21 [PATCH] erofs-utils: check the return value of erofs_d_alloc Huang Jianan via Linux-erofs
2021-11-17 10:21 ` [PATCH] erofs-utils: fix memory leak when get blob chunk Huang Jianan via Linux-erofs
@ 2021-11-18 10:04 ` Yue Hu
1 sibling, 0 replies; 3+ messages in thread
From: Yue Hu @ 2021-11-18 10:04 UTC (permalink / raw)
To: Huang Jianan via Linux-erofs; +Cc: zhangshiming, yh, guanyuwei, guoweichao
On Wed, 17 Nov 2021 18:21:19 +0800
Huang Jianan via Linux-erofs <linux-erofs@lists.ozlabs.org> wrote:
> Need to check whether the allocation of erofs_dentry is successful.
>
> Signed-off-by: Huang Jianan <huangjianan@oppo.com>
> ---
> lib/inode.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/lib/inode.c b/lib/inode.c
> index 5cbfc78..2fa74e2 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -162,11 +162,15 @@ int erofs_prepare_dir_file(struct erofs_inode *dir, unsigned int nr_subdirs)
>
> /* dot is pointed to the current dir inode */
> d = erofs_d_alloc(dir, ".");
> + if (IS_ERR(d))
> + return PTR_ERR(d);
> d->inode = erofs_igrab(dir);
> d->type = EROFS_FT_DIR;
>
> /* dotdot is pointed to the parent dir */
> d = erofs_d_alloc(dir, "..");
> + if (IS_ERR(d))
> + return PTR_ERR(d);
> d->inode = erofs_igrab(dir->i_parent);
> d->type = EROFS_FT_DIR;
>
Looks good to me
Reviewed-by: Yue Hu <huyue2@yulong.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-18 10:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 10:21 [PATCH] erofs-utils: check the return value of erofs_d_alloc Huang Jianan via Linux-erofs
2021-11-17 10:21 ` [PATCH] erofs-utils: fix memory leak when get blob chunk Huang Jianan via Linux-erofs
2021-11-18 10:04 ` [PATCH] erofs-utils: check the return value of erofs_d_alloc Yue Hu
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).