Currently, `z_erofs_compress_exit` does not free `zmgr` if compression
is disabled, causing a memory leak. Fix it.

Fixes: a110eea6d80a ("erofs-utils: mkfs: avoid erroring out if `zmgr` is 
uninitialized")
Signed-off-by: Yifan Zhao <[email protected]>
---
change since v2:
- do not remove early exit in `z_erofs_compress_exit`.

 lib/compress.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/compress.c b/lib/compress.c
index a57bb6a..2059e19 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -2140,6 +2140,9 @@ int z_erofs_compress_exit(struct erofs_sb_info *sbi)
                        return ret;
        }
 
+       if (sbi->zmgr)
+               free(sbi->zmgr);
+
        if (z_erofs_mt_enabled) {
 #ifdef EROFS_MT_ENABLED
                ret = erofs_destroy_workqueue(&z_erofs_mt_ctrl.wq);
-- 
2.43.0


Reply via email to