Skip to content

Commit 27d2f10

Browse files
ea1davisAndreas Gruenbacher
authored andcommitted
gfs2: check sb_min_blocksize return value
Check the return value of sb_min_blocksize(): it will be 0 when the requested block size is invalid. In addition, check the return value of sb_set_blocksize() as well. Reported-by: [email protected] Signed-off-by: Edward Adam Davis <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent ae9f3bd commit 27d2f10

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/gfs2/ops_fstype.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ static int init_sb(struct gfs2_sbd *sdp, int silent)
489489
sdp->sd_sb.sb_bsize, (unsigned int)PAGE_SIZE);
490490
goto out;
491491
}
492-
sb_set_blocksize(sb, sdp->sd_sb.sb_bsize);
492+
ret = -EINVAL;
493+
if (!sb_set_blocksize(sb, sdp->sd_sb.sb_bsize))
494+
goto out;
493495

494496
/* Get the root inode */
495497
no_addr = sdp->sd_sb.sb_root_dir.no_addr;
@@ -1158,6 +1160,9 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
11581160
/* Set up the buffer cache and fill in some fake block size values
11591161
to allow us to read-in the on-disk superblock. */
11601162
sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512);
1163+
error = -EINVAL;
1164+
if (!sdp->sd_sb.sb_bsize)
1165+
goto fail_free;
11611166
sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
11621167
sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
11631168
sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);

0 commit comments

Comments
 (0)