From: Ingyu Jang <ingyujang25@gmail.com>
To: phillip@squashfs.org.uk
Cc: linux-kernel@vger.kernel.org, Ingyu Jang <ingyujang25@gmail.com>
Subject: [PATCH] squashfs: Fix ambiguity in get_comp_opts() return value handling
Date: Fri, 17 Jan 2025 04:11:49 +0900 [thread overview]
Message-ID: <20250116191149.2288889-1-ingyujang25@gmail.com> (raw)
The return value of the function get_comp_opts() is
checked using IS_ERR().
However, it can return NULL when squashfs_comp_opts() returns NULL,
causing ambiguity in its return value.
This makes it difficult for the caller to clearly determine whether the
function succeeded or an error occurred.
Additionally, it may cause a NULL pointer dereference.
To address this issue, get_comp_opts() has been modified to always
return an appropriate error code wrapped with ERR_PTR() in case of
failure.
With this change, the caller can reliably distinguish between success
and error cases using IS_ERR().
Signed-off-by: Ingyu Jang <ingyujang25@gmail.com>
---
fs/squashfs/decompressor.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c
index a676084be27e..2988f2d4220c 100644
--- a/fs/squashfs/decompressor.c
+++ b/fs/squashfs/decompressor.c
@@ -117,6 +117,8 @@ static void *get_comp_opts(struct super_block *sb, unsigned short flags)
}
comp_opts = squashfs_comp_opts(msblk, buffer, length);
+ if (!comp_opts)
+ comp_opts = ERR_PTR(-EINVAL);
out:
kfree(actor);
--
2.34.1
reply other threads:[~2025-01-16 19:15 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=20250116191149.2288889-1-ingyujang25@gmail.com \
--to=ingyujang25@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@squashfs.org.uk \
/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
all inboxes | Powered by JetHome®