diff mbox series

cramfs: fix usage on non-MTD device

Message ID nycvar.YSQ.7.76.1910191518180.1546@knanqh.ubzr (mailing list archive)
State New, archived
Headers show
Series cramfs: fix usage on non-MTD device | expand

Commit Message

Nicolas Pitre Oct. 19, 2019, 7:24 p.m. UTC
From: Maxime Bizon <mbizon@freebox.fr>

When both CONFIG_CRAMFS_MTD and CONFIG_CRAMFS_BLOCKDEV are enabled, if
we fail to mount on MTD, we don't try on block device.

Fixes: 74f78fc5ef43 ("vfs: Convert cramfs to use the new mount API")

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
---
 fs/cramfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Howells Oct. 21, 2019, 1:45 p.m. UTC | #1
Nicolas Pitre <nico@fluxnic.net> wrote:

> From: Maxime Bizon <mbizon@freebox.fr>
> 
> When both CONFIG_CRAMFS_MTD and CONFIG_CRAMFS_BLOCKDEV are enabled, if
> we fail to mount on MTD, we don't try on block device.
> 
> Fixes: 74f78fc5ef43 ("vfs: Convert cramfs to use the new mount API")
> 
> Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
> Signed-off-by: Nicolas Pitre <nico@fluxnic.net>

Acked-by: David Howells <dhowells@redhat.com>
Al Viro Oct. 21, 2019, 2:04 p.m. UTC | #2
On Mon, Oct 21, 2019 at 02:45:39PM +0100, David Howells wrote:
> Nicolas Pitre <nico@fluxnic.net> wrote:
> 
> > From: Maxime Bizon <mbizon@freebox.fr>
> > 
> > When both CONFIG_CRAMFS_MTD and CONFIG_CRAMFS_BLOCKDEV are enabled, if
> > we fail to mount on MTD, we don't try on block device.
> > 
> > Fixes: 74f78fc5ef43 ("vfs: Convert cramfs to use the new mount API")
> > 
> > Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
> > Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
> 
> Acked-by: David Howells <dhowells@redhat.com>

FWIW, the thing that worries me here is the possibility of
side effects on fs_context in case if fill_super fails really
late...  OTOH, cramfs one seems to be safe in that respect.

OK, will apply, but that's fairly brittle and needs to be
documented.  If we *ever* grow non-trivial options parsing
there, that'll be a serious landmine.  If something gets
transferred from fs_context into a superblock, which
fails later in setup and takes that object with it, the
second part (get_tree_bdev()) would be in trouble.
diff mbox series

Patch

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index d12ea28836a5..2f04024c3588 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -958,8 +958,8 @@  static int cramfs_get_tree(struct fs_context *fc)
 
 	if (IS_ENABLED(CONFIG_CRAMFS_MTD)) {
 		ret = get_tree_mtd(fc, cramfs_mtd_fill_super);
-		if (ret < 0)
-			return ret;
+		if (!ret)
+			return 0;
 	}
 	if (IS_ENABLED(CONFIG_CRAMFS_BLOCKDEV))
 		ret = get_tree_bdev(fc, cramfs_blkdev_fill_super);