git: 38389acc59fc - main - ext2fs: fix potential memory leak in ext4_ext_grow_indepth()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 17 Dec 2022 18:20:51 UTC
The branch main has been updated by pfg:
URL: https://cgit.FreeBSD.org/src/commit/?id=38389acc59fcb014c5c9beed06a6f13835808b89
commit 38389acc59fcb014c5c9beed06a6f13835808b89
Author: Pedro F. Giffuni <pfg@FreeBSD.org>
AuthorDate: 2022-12-17 18:19:51 +0000
Commit: Pedro F. Giffuni <pfg@FreeBSD.org>
CommitDate: 2022-12-17 18:19:51 +0000
ext2fs: fix potential memory leak in ext4_ext_grow_indepth()
PR: 265071
---
sys/fs/ext2fs/ext2_extents.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sys/fs/ext2fs/ext2_extents.c b/sys/fs/ext2fs/ext2_extents.c
index 3d24db4b396b..17ae8655cddc 100644
--- a/sys/fs/ext2fs/ext2_extents.c
+++ b/sys/fs/ext2fs/ext2_extents.c
@@ -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));
@@ -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;