[PATCH] erofs-utils: fix memory leak when get blob chunk

Huang Jianan huangjianan at oppo.com
Wed Nov 17 21:21:20 AEDT 2021


Release memory allocated for chunk before return error.

Signed-off-by: Huang Jianan <huangjianan at 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



More information about the Linux-erofs mailing list