From: Utkal Singh <singhutkal015@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: xiang@kernel.org, Utkal Singh <singhutkal015@gmail.com>,
Utkal Singh <utkalsingh059@gmail.com>
Subject: [PATCH] erofs-utils: lib: fix wrong NULL check after erofs_balloc() in metabox
Date: Sun, 15 Mar 2026 16:02:16 +0000 [thread overview]
Message-ID: <20260315160216.17079-1-singhutkal015@gmail.com> (raw)
erofs_balloc() returns an error pointer via ERR_PTR(-errno) on failure,
never NULL. The previous check:
if (!bh)
fails to detect error pointers since ERR_PTR encodes errors as non-zero
pointers near ULONG_MAX. This causes PTR_ERR(bh) on the next line to be
unreachable, and the subsequent erofs_mapbh() call to receive an invalid
pointer, potentially causing a crash or silent memory corruption.
Replace with the correct IS_ERR() pattern which properly detects all
error pointer values returned by erofs_balloc().
Fixes: 7928074b7643 ("erofs-utils: introduce metadata compression [metabox]")
Signed-off-by: Utkal Singh <utkalsingh059@gmail.com>
---
lib/metabox.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/metabox.c b/lib/metabox.c
index d6abd51..12706aa 100644
--- a/lib/metabox.c
+++ b/lib/metabox.c
@@ -127,7 +127,7 @@ int erofs_metazone_flush(struct erofs_sb_info *sbi)
if (!m2gr)
return 0;
bh = erofs_balloc(sbi->bmgr, DATA, 0, 0);
- if (!bh)
+ if (IS_ERR(bh))
return PTR_ERR(bh);
erofs_mapbh(NULL, bh->block);
pos_out = erofs_btell(bh, false);
--
2.43.0
reply other threads:[~2026-03-15 16:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260315160216.17079-1-singhutkal015@gmail.com \
--to=singhutkal015@gmail.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=utkalsingh059@gmail.com \
--cc=xiang@kernel.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