Skip to content

Commit

Permalink
fs/adfs: super: fix use-after-free bug
Browse files Browse the repository at this point in the history
[ Upstream commit 5808b14a1f52554de612fee85ef517199855e310 ]

Fix a use-after-free bug during filesystem initialisation, where we
access the disc record (which is stored in a buffer) after we have
released the buffer.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Russell King authored and gregkh committed Aug 6, 2019
1 parent 85d854b commit a093208
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/adfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
struct buffer_head *bh;
struct object_info root_obj;
unsigned char *b_data;
unsigned int blocksize;
struct adfs_sb_info *asb;
struct inode *root;
int ret = -EINVAL;
Expand Down Expand Up @@ -420,8 +421,10 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
goto error_free_bh;
}

blocksize = 1 << dr->log2secsize;
brelse(bh);
if (sb_set_blocksize(sb, 1 << dr->log2secsize)) {

if (sb_set_blocksize(sb, blocksize)) {
bh = sb_bread(sb, ADFS_DISCRECORD / sb->s_blocksize);
if (!bh) {
adfs_error(sb, "couldn't read superblock on "
Expand Down

0 comments on commit a093208

Please sign in to comment.