]> git.ipfire.org Git - thirdparty/kernel/linux.git/blobdiff - fs/f2fs/super.c
f2fs: fix double free of f2fs_sb_info
[thirdparty/kernel/linux.git] / fs / f2fs / super.c
index e965b4ec366c6d3518df5af32f3d0ce90fd29d0e..d45ab0992ae5947e6f89628e8e8829c548645d26 100644 (file)
@@ -1422,11 +1422,6 @@ default_check:
                }
        }
 
-       if (test_opt(sbi, DISABLE_CHECKPOINT) && f2fs_lfs_mode(sbi)) {
-               f2fs_err(sbi, "LFS is not compatible with checkpoint=disable");
-               return -EINVAL;
-       }
-
        if (test_opt(sbi, ATGC) && f2fs_lfs_mode(sbi)) {
                f2fs_err(sbi, "LFS is not compatible with ATGC");
                return -EINVAL;
@@ -3361,6 +3356,14 @@ loff_t max_file_blocks(struct inode *inode)
        leaf_count *= NIDS_PER_BLOCK;
        result += leaf_count;
 
+       /*
+        * For compatibility with FSCRYPT_POLICY_FLAG_IV_INO_LBLK_{64,32} with
+        * a 4K crypto data unit, we must restrict the max filesize to what can
+        * fit within U32_MAX + 1 data units.
+        */
+
+       result = min(result, (((loff_t)U32_MAX + 1) * 4096) >> F2FS_BLKSIZE_BITS);
+
        return result;
 }
 
@@ -4740,7 +4743,7 @@ try_onemore:
 #ifdef CONFIG_QUOTA
        f2fs_recover_quota_end(sbi, quota_enabled);
 #endif
-
+reset_checkpoint:
        /*
         * If the f2fs is not readonly and fsync data recovery succeeds,
         * check zoned block devices' write pointer consistency.
@@ -4751,7 +4754,6 @@ try_onemore:
                        goto free_meta;
        }
 
-reset_checkpoint:
        f2fs_init_inmem_curseg(sbi);
 
        /* f2fs_recover_fsync_data() cleared this already */
@@ -4878,6 +4880,7 @@ free_sbi:
        if (sbi->s_chksum_driver)
                crypto_free_shash(sbi->s_chksum_driver);
        kfree(sbi);
+       sb->s_fs_info = NULL;
 
        /* give only one another chance */
        if (retry_cnt > 0 && skip_recovery) {