Skip to content

Commit

Permalink
ext2fs: fix potential memory leak in ext4_ext_grow_indepth()
Browse files Browse the repository at this point in the history
PR:	265071
  • Loading branch information
pgiffuni committed Dec 17, 2022
1 parent 4d903a1 commit 38389ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sys/fs/ext2fs/ext2_extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,10 @@ ext4_ext_grow_indepth(struct inode *ip, struct ext4_extent_path *path,
return (error);

bp = getblk(ip->i_devvp, fsbtodb(fs, newblk), fs->e2fs_bsize, 0, 0, 0);
if (!bp)
if (!bp) {
ext4_ext_blkfree(ip, newblk, 1, 0);
return (EIO);
}

/* Move top-level index/leaf into new block. */
memmove(bp->b_data, curpath->ep_header, sizeof(ip->i_data));
Expand All @@ -1116,8 +1118,10 @@ ext4_ext_grow_indepth(struct inode *ip, struct ext4_extent_path *path,

ext2_extent_blk_csum_set(ip, bp->b_data);
error = bwrite(bp);
if (error)
if (error) {
ext4_ext_blkfree(ip, newblk, 1, 0);
goto out;
}

bp = NULL;

Expand Down

0 comments on commit 38389ac

Please sign in to comment.