@@ -1259,7 +1259,7 @@ static void ext4_put_super(struct super_block *sb)
12591259 struct ext4_sb_info * sbi = EXT4_SB (sb );
12601260 struct ext4_super_block * es = sbi -> s_es ;
12611261 int aborted = 0 ;
1262- int i , err ;
1262+ int err ;
12631263
12641264 /*
12651265 * Unregister sysfs before destroying jbd2 journal.
@@ -1311,7 +1311,7 @@ static void ext4_put_super(struct super_block *sb)
13111311 ext4_flex_groups_free (sbi );
13121312 ext4_percpu_param_destroy (sbi );
13131313#ifdef CONFIG_QUOTA
1314- for (i = 0 ; i < EXT4_MAXQUOTAS ; i ++ )
1314+ for (int i = 0 ; i < EXT4_MAXQUOTAS ; i ++ )
13151315 kfree (get_qf_name (sb , sbi , i ));
13161316#endif
13171317
@@ -5196,10 +5196,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
51965196 struct ext4_sb_info * sbi = EXT4_SB (sb );
51975197 ext4_fsblk_t logical_sb_block ;
51985198 struct inode * root ;
5199- int ret = - ENOMEM ;
5200- unsigned int i ;
52015199 int needs_recovery ;
5202- int err = 0 ;
5200+ int err ;
52035201 ext4_group_t first_not_zeroed ;
52045202 struct ext4_fs_context * ctx = fc -> fs_private ;
52055203 int silent = fc -> sb_flags & SB_SILENT ;
@@ -5212,8 +5210,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52125210 sbi -> s_sectors_written_start =
52135211 part_stat_read (sb -> s_bdev , sectors [STAT_WRITE ]);
52145212
5215- /* -EINVAL is default */
5216- ret = - EINVAL ;
52175213 err = ext4_load_super (sb , & logical_sb_block , silent );
52185214 if (err )
52195215 goto out_fail ;
@@ -5239,7 +5235,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52395235 */
52405236 sbi -> s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT ;
52415237
5242- if (ext4_inode_info_init (sb , es ))
5238+ err = ext4_inode_info_init (sb , es );
5239+ if (err )
52435240 goto failed_mount ;
52445241
52455242 err = parse_apply_sb_mount_options (sb , ctx );
@@ -5255,10 +5252,12 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52555252
52565253 ext4_apply_options (fc , sb );
52575254
5258- if (ext4_encoding_init (sb , es ))
5255+ err = ext4_encoding_init (sb , es );
5256+ if (err )
52595257 goto failed_mount ;
52605258
5261- if (ext4_check_journal_data_mode (sb ))
5259+ err = ext4_check_journal_data_mode (sb );
5260+ if (err )
52625261 goto failed_mount ;
52635262
52645263 sb -> s_flags = (sb -> s_flags & ~SB_POSIXACL ) |
@@ -5267,18 +5266,22 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52675266 /* i_version is always enabled now */
52685267 sb -> s_flags |= SB_I_VERSION ;
52695268
5270- if (ext4_check_feature_compatibility (sb , es , silent ))
5269+ err = ext4_check_feature_compatibility (sb , es , silent );
5270+ if (err )
52715271 goto failed_mount ;
52725272
5273- if (ext4_block_group_meta_init (sb , silent ))
5273+ err = ext4_block_group_meta_init (sb , silent );
5274+ if (err )
52745275 goto failed_mount ;
52755276
52765277 ext4_hash_info_init (sb );
52775278
5278- if (ext4_handle_clustersize (sb ))
5279+ err = ext4_handle_clustersize (sb );
5280+ if (err )
52795281 goto failed_mount ;
52805282
5281- if (ext4_check_geometry (sb , es ))
5283+ err = ext4_check_geometry (sb , es );
5284+ if (err )
52825285 goto failed_mount ;
52835286
52845287 timer_setup (& sbi -> s_err_report , print_daily_error_info , 0 );
@@ -5289,8 +5292,8 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52895292 if (err )
52905293 goto failed_mount3 ;
52915294
5292- /* Register extent status tree shrinker */
5293- if (ext4_es_register_shrinker ( sbi ) )
5295+ err = ext4_es_register_shrinker ( sbi );
5296+ if (err )
52945297 goto failed_mount3 ;
52955298
52965299 sbi -> s_stripe = ext4_get_stripe_size (sbi );
@@ -5329,10 +5332,13 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
53295332 ext4_has_feature_orphan_present (sb ) ||
53305333 ext4_has_feature_journal_needs_recovery (sb ));
53315334
5332- if (ext4_has_feature_mmp (sb ) && !sb_rdonly (sb ))
5333- if (ext4_multi_mount_protect (sb , le64_to_cpu (es -> s_mmp_block )))
5335+ if (ext4_has_feature_mmp (sb ) && !sb_rdonly (sb )) {
5336+ err = ext4_multi_mount_protect (sb , le64_to_cpu (es -> s_mmp_block ));
5337+ if (err )
53345338 goto failed_mount3a ;
5339+ }
53355340
5341+ err = - EINVAL ;
53365342 /*
53375343 * The first inode we look at is the journal inode. Don't try
53385344 * root first: it may be modified in the journal!
@@ -5384,6 +5390,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
53845390 if (!sbi -> s_ea_block_cache ) {
53855391 ext4_msg (sb , KERN_ERR ,
53865392 "Failed to create ea_block_cache" );
5393+ err = - EINVAL ;
53875394 goto failed_mount_wq ;
53885395 }
53895396
@@ -5392,6 +5399,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
53925399 if (!sbi -> s_ea_inode_cache ) {
53935400 ext4_msg (sb , KERN_ERR ,
53945401 "Failed to create ea_inode_cache" );
5402+ err = - EINVAL ;
53955403 goto failed_mount_wq ;
53965404 }
53975405 }
@@ -5426,7 +5434,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
54265434 alloc_workqueue ("ext4-rsv-conversion" , WQ_MEM_RECLAIM | WQ_UNBOUND , 1 );
54275435 if (!EXT4_SB (sb )-> rsv_conversion_wq ) {
54285436 printk (KERN_ERR "EXT4-fs: failed to create workqueue\n" );
5429- ret = - ENOMEM ;
5437+ err = - ENOMEM ;
54305438 goto failed_mount4 ;
54315439 }
54325440
@@ -5438,28 +5446,28 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
54385446 root = ext4_iget (sb , EXT4_ROOT_INO , EXT4_IGET_SPECIAL );
54395447 if (IS_ERR (root )) {
54405448 ext4_msg (sb , KERN_ERR , "get root inode failed" );
5441- ret = PTR_ERR (root );
5449+ err = PTR_ERR (root );
54425450 root = NULL ;
54435451 goto failed_mount4 ;
54445452 }
54455453 if (!S_ISDIR (root -> i_mode ) || !root -> i_blocks || !root -> i_size ) {
54465454 ext4_msg (sb , KERN_ERR , "corrupt root inode, run e2fsck" );
54475455 iput (root );
5456+ err = - EFSCORRUPTED ;
54485457 goto failed_mount4 ;
54495458 }
54505459
54515460 sb -> s_root = d_make_root (root );
54525461 if (!sb -> s_root ) {
54535462 ext4_msg (sb , KERN_ERR , "get root dentry failed" );
5454- ret = - ENOMEM ;
5463+ err = - ENOMEM ;
54555464 goto failed_mount4 ;
54565465 }
54575466
5458- ret = ext4_setup_super (sb , es , sb_rdonly (sb ));
5459- if (ret == - EROFS ) {
5467+ err = ext4_setup_super (sb , es , sb_rdonly (sb ));
5468+ if (err == - EROFS ) {
54605469 sb -> s_flags |= SB_RDONLY ;
5461- ret = 0 ;
5462- } else if (ret )
5470+ } else if (err )
54635471 goto failed_mount4a ;
54645472
54655473 ext4_set_resv_clusters (sb );
@@ -5503,15 +5511,16 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
55035511 sbi -> s_journal -> j_commit_callback =
55045512 ext4_journal_commit_callback ;
55055513
5506- if (ext4_percpu_param_init (sbi ))
5514+ err = ext4_percpu_param_init (sbi );
5515+ if (err )
55075516 goto failed_mount6 ;
55085517
55095518 if (ext4_has_feature_flex_bg (sb ))
55105519 if (!ext4_fill_flex_info (sb )) {
55115520 ext4_msg (sb , KERN_ERR ,
55125521 "unable to initialize "
55135522 "flex_bg meta info!" );
5514- ret = - ENOMEM ;
5523+ err = - ENOMEM ;
55155524 goto failed_mount6 ;
55165525 }
55175526
@@ -5628,7 +5637,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
56285637#endif
56295638
56305639#ifdef CONFIG_QUOTA
5631- for (i = 0 ; i < EXT4_MAXQUOTAS ; i ++ )
5640+ for (unsigned int i = 0 ; i < EXT4_MAXQUOTAS ; i ++ )
56325641 kfree (get_qf_name (sb , sbi , i ));
56335642#endif
56345643 fscrypt_free_dummy_policy (& sbi -> s_dummy_enc_policy );
@@ -5637,7 +5646,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
56375646 ext4_blkdev_remove (sbi );
56385647out_fail :
56395648 sb -> s_fs_info = NULL ;
5640- return err ? err : ret ;
5649+ return err ;
56415650}
56425651
56435652static int ext4_fill_super (struct super_block * sb , struct fs_context * fc )
@@ -6565,12 +6574,12 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
65656574 goto restore_opts ;
65666575
65676576 sb -> s_flags &= ~SB_RDONLY ;
6568- if (ext4_has_feature_mmp (sb ))
6569- if ( ext4_multi_mount_protect (sb ,
6570- le64_to_cpu (es -> s_mmp_block ))) {
6571- err = - EROFS ;
6577+ if (ext4_has_feature_mmp (sb )) {
6578+ err = ext4_multi_mount_protect (sb ,
6579+ le64_to_cpu (es -> s_mmp_block ));
6580+ if ( err )
65726581 goto restore_opts ;
6573- }
6582+ }
65746583#ifdef CONFIG_QUOTA
65756584 enable_quota = 1 ;
65766585#endif
0 commit comments