]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
efivarfs: Move efivar availability check into FS context init
authorArd Biesheuvel <ardb@kernel.org>
Fri, 8 Dec 2023 16:39:27 +0000 (17:39 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Mon, 11 Dec 2023 10:19:17 +0000 (11:19 +0100)
Instead of checking whether or not EFI variables are available when
creating the superblock, check it one step earlier, when initializing
the FS context for the mount. This way, no FS context will be created at
all, and we can drop the second check at .kill_sb() time entirely.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
fs/efivarfs/super.c

index 869537f1a550dde8e6d01ee7cb410056ca27b208..d4530e4eac06ae714636957b2cd4139caec16726 100644 (file)
@@ -296,9 +296,6 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
        struct dentry *root;
        int err;
 
-       if (!efivar_is_available())
-               return -EOPNOTSUPP;
-
        sb->s_maxbytes          = MAX_LFS_FILESIZE;
        sb->s_blocksize         = PAGE_SIZE;
        sb->s_blocksize_bits    = PAGE_SHIFT;
@@ -354,6 +351,9 @@ static int efivarfs_init_fs_context(struct fs_context *fc)
 {
        struct efivarfs_fs_info *sfi;
 
+       if (!efivar_is_available())
+               return -EOPNOTSUPP;
+
        sfi = kzalloc(sizeof(*sfi), GFP_KERNEL);
        if (!sfi)
                return -ENOMEM;
@@ -370,9 +370,6 @@ static void efivarfs_kill_sb(struct super_block *sb)
 {
        kill_litter_super(sb);
 
-       if (!efivar_is_available())
-               return;
-
        /* Remove all entries and destroy */
        efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL);
 }