Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH 1/7] erofs-utils: lib: fix `ictx` leak in the failure path
Date: Tue, 30 Jun 2026 10:52:18 +0800	[thread overview]
Message-ID: <20260630025224.3955763-1-hsiangkao@linux.alibaba.com> (raw)

Coverity-id: 647272
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 lib/compress.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/compress.c b/lib/compress.c
index e57de425be28..f7ad5a1c6c87 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1881,8 +1881,7 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,
 			if (!erofs_sb_has_48bit(sbi)) {
 				erofs_err("Unaligned compressed extents must be used with the 48bit encoded extent layout",
 					  ictx->max_compressed_extent_size);
-				free(ictx);
-				return ERR_PTR(-EINVAL);
+				goto err_out;
 			}
 			ictx->data_unaligned = true;
 		} else {
@@ -1894,7 +1893,7 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,
 		if (ictx->max_compressed_extent_size < erofs_blksiz(sbi)) {
 			erofs_err("Maximum compressed extent size (%u) must be at least the block size (%u)",
 				  ictx->max_compressed_extent_size, erofs_blksiz(sbi));
-			return ERR_PTR(-EINVAL);
+			goto err_out;
 		}
 	} else {
 		ictx->max_compressed_extent_size =
@@ -1910,6 +1909,9 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,
 	ictx->fragemitted = false;
 	ictx->dedupe = false;
 	return ictx;
+err_out:
+	free(ictx);
+	return ERR_PTR(-EINVAL);
 }
 
 void erofs_bind_compressed_file_with_fd(struct z_erofs_compress_ictx *ictx,
-- 
2.43.5



             reply	other threads:[~2026-06-30  2:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30  2:52 Gao Xiang [this message]
2026-06-30  2:52 ` [PATCH 2/7] erofs-utils: lib: silence `INTEGER_OVERFLOW` Gao Xiang
2026-06-30  2:52 ` [PATCH 3/7] erofs-utils: lib: fix `PRINTF_ARGS` Gao Xiang
2026-06-30  2:52 ` [PATCH 4/7] erofs-utils: mount: fix `RESOURCE_LEAK` Gao Xiang
2026-06-30  2:52 ` [PATCH 5/7] erofs-utils: lib: fix `STRING_NULL` in nbd.c Gao Xiang
2026-06-30  2:52 ` [PATCH 6/7] erofs-utils: mount: fix `RESOURCE_LEAK` Gao Xiang
2026-06-30  2:52 ` [PATCH 7/7] erofs-utils: lib: silence `INTEGER_OVERFLOW` Gao Xiang

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=20260630025224.3955763-1-hsiangkao@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox