All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yifan Zhao <stopire@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: Yifan Zhao <stopire@gmail.com>
Subject: [PATCH v3 2/2] erofs-utils: lib: fix memory leak in z_erofs_compress_exit
Date: Tue, 15 Jul 2025 23:21:11 +0800	[thread overview]
Message-ID: <20250715152111.15305-1-stopire@gmail.com> (raw)
In-Reply-To: <c6316256-548b-48c7-aacd-ee863968688d@linux.alibaba.com>

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 <stopire@gmail.com>
---
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	other threads:[~2025-07-15 15:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-11 16:16 [PATCH 0/2] two minor fixes for erofs-utils lib Yifan Zhao
2025-07-11 16:16 ` [PATCH 1/2] erofs-utils: lib: fix uninitialized variable access in bmgr Yifan Zhao
2025-07-11 16:40   ` Gao Xiang
2025-07-11 16:16 ` [PATCH 2/2] erofs-utils: lib: add guard clause for z_erofs_compress_init Yifan Zhao
2025-07-11 16:39   ` Gao Xiang
2025-07-14 16:55     ` [PATCH v2 2/2] erofs-utils: lib: fix memory leak in z_erofs_compress_exit Yifan Zhao
2025-07-14 17:09       ` Gao Xiang
2025-07-15 15:21         ` Yifan Zhao [this message]

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=20250715152111.15305-1-stopire@gmail.com \
    --to=stopire@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.