[PATCH 2/2] fs: jffs2: refuse to mount non-MTD devices
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Nov 3 06:32:30 PST 2026
From: Ahmad Fatoum <a.fatoum at 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 at 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
More information about the barebox
mailing list