From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 2/2] fs: jffs2: refuse to mount non-MTD devices
Date: Tue, 3 Nov 2026 15:32:30 +0100 [thread overview]
Message-ID: <20261103143234.855394-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20261103143234.855394-1-a.fatoum@pengutronix.de>
From: Ahmad Fatoum <a.fatoum@barebox.org>
jffs2 only works on MTD, but nothing keeps it from being probed for
other devices. mount -t jffs2 on a block device leaves the MTD pointer
NULL and jffs2_do_fill_super() dereferences it right away.
Let's fail the probe instead, like ubifs does when it's not given a UBI
volume.
Fixes: 831b3312e5fe ("fs: jffs2: add initial support for reading jffs2")
Assisted-by: Claude:opus-5.5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
fs/jffs2/fs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 84f39a0f2a24..8cbe15850e37 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -407,6 +407,11 @@ static int jffs2_probe(struct device *dev)
if (ret)
goto err_out;
+ if (!fsdev->cdev->mtd) {
+ dev_err(dev, "%s is not an MTD device\n", fsdev->backingstore);
+ return -EINVAL;
+ }
+
ctx = kzalloc(sizeof(struct jffs2_sb_info), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
--
2.47.3
prev parent reply other threads:[~2026-11-03 14:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 14:32 [PATCH 1/2] fs: pstore: don't claim uImages Ahmad Fatoum
2026-11-03 14:32 ` Ahmad Fatoum [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=20261103143234.855394-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.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