aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2012-11-08 15:16:54 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-11-08 15:16:54 -0500
commit07aa2ea13814ea60d12f7330b6d5ccfdb0c3ba4d (patch)
tree375224d5cff047d0d862cc66a48c4300d77b9c40 /fs/ext4/super.c
parent24ec19b0ae83a385ad9c55520716da671274b96c (diff)
ext4: fix error handling in ext4_fill_super()
There are some places in ext4_fill_super() where we would not return proper error code if something fails. The confusion is caused probably due to the fact that we have two "kind-of" return variables 'ret'and 'err'. 'ret' is used to return error code from ext4_fill_super() where err is used to store return values from other functions within ext4_fill_super(). However some places were missing the obligatory 'ret = err'. We could put the assignment where it is missing, but we can have better "future proof" solution. Or we could convert the code to use just one, but it would require more rewrites. This commit fixes the problem by returning value from 'err' variable if it is set and 'ret' otherwise in error handling branch of the ext4_fill_super(). The reasoning is that 'ret' value is often set to default "-EINVAL" or explicit value, where 'err' is used to store return value from other functions and should be otherwise zero. https://bugzilla.kernel.org/show_bug.cgi?id=48431 Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6729470ee1a4..18e89fafebd1 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3256,7 +3256,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3256 unsigned int i; 3256 unsigned int i;
3257 int needs_recovery, has_huge_files, has_bigalloc; 3257 int needs_recovery, has_huge_files, has_bigalloc;
3258 __u64 blocks_count; 3258 __u64 blocks_count;
3259 int err; 3259 int err = 0;
3260 unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO; 3260 unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
3261 ext4_group_t first_not_zeroed; 3261 ext4_group_t first_not_zeroed;
3262 3262
@@ -3282,6 +3282,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3282 for (cp = sb->s_id; (cp = strchr(cp, '/'));) 3282 for (cp = sb->s_id; (cp = strchr(cp, '/'));)
3283 *cp = '!'; 3283 *cp = '!';
3284 3284
3285 /* -EINVAL is default */
3285 ret = -EINVAL; 3286 ret = -EINVAL;
3286 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); 3287 blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE);
3287 if (!blocksize) { 3288 if (!blocksize) {
@@ -3659,7 +3660,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3659 " too large to mount safely on this system"); 3660 " too large to mount safely on this system");
3660 if (sizeof(sector_t) < 8) 3661 if (sizeof(sector_t) < 8)
3661 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); 3662 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled");
3662 ret = err;
3663 goto failed_mount; 3663 goto failed_mount;
3664 } 3664 }
3665 3665
@@ -3767,7 +3767,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3767 } 3767 }
3768 if (err) { 3768 if (err) {
3769 ext4_msg(sb, KERN_ERR, "insufficient memory"); 3769 ext4_msg(sb, KERN_ERR, "insufficient memory");
3770 ret = err;
3771 goto failed_mount3; 3770 goto failed_mount3;
3772 } 3771 }
3773 3772
@@ -3894,8 +3893,8 @@ no_journal:
3894 if (es->s_overhead_clusters) 3893 if (es->s_overhead_clusters)
3895 sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters); 3894 sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
3896 else { 3895 else {
3897 ret = ext4_calculate_overhead(sb); 3896 err = ext4_calculate_overhead(sb);
3898 if (ret) 3897 if (err)
3899 goto failed_mount_wq; 3898 goto failed_mount_wq;
3900 } 3899 }
3901 3900
@@ -3907,6 +3906,7 @@ no_journal:
3907 alloc_workqueue("ext4-dio-unwritten", WQ_MEM_RECLAIM | WQ_UNBOUND, 1); 3906 alloc_workqueue("ext4-dio-unwritten", WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
3908 if (!EXT4_SB(sb)->dio_unwritten_wq) { 3907 if (!EXT4_SB(sb)->dio_unwritten_wq) {
3909 printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); 3908 printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n");
3909 ret = -ENOMEM;
3910 goto failed_mount_wq; 3910 goto failed_mount_wq;
3911 } 3911 }
3912 3912
@@ -4009,8 +4009,8 @@ no_journal:
4009 /* Enable quota usage during mount. */ 4009 /* Enable quota usage during mount. */
4010 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && 4010 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) &&
4011 !(sb->s_flags & MS_RDONLY)) { 4011 !(sb->s_flags & MS_RDONLY)) {
4012 ret = ext4_enable_quotas(sb); 4012 err = ext4_enable_quotas(sb);
4013 if (ret) 4013 if (err)
4014 goto failed_mount7; 4014 goto failed_mount7;
4015 } 4015 }
4016#endif /* CONFIG_QUOTA */ 4016#endif /* CONFIG_QUOTA */
@@ -4089,7 +4089,7 @@ out_fail:
4089 kfree(sbi); 4089 kfree(sbi);
4090out_free_orig: 4090out_free_orig:
4091 kfree(orig_data); 4091 kfree(orig_data);
4092 return ret; 4092 return err ? err : ret;
4093} 4093}
4094 4094
4095/* 4095/*