FreeBSD Bugzilla – Attachment 235103 Details for
Bug 265071
ext2fs: fix potential memory leak in ext4_ext_grow_indepth()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
a possible patch to this bug.
ext2fs-fix-potential-memory-leak-in-ext4_ext_grow_in.patch (text/plain), 1.50 KB, created by
niejianglei2021@163.com
on 2022-07-07 07:16:41 UTC
(
hide
)
Description:
a possible patch to this bug.
Filename:
MIME Type:
Creator:
niejianglei2021@163.com
Created:
2022-07-07 07:16:41 UTC
Size:
1.50 KB
patch
obsolete
>From 049cc2231eec716272dcab66798c7990ed3479fd Mon Sep 17 00:00:00 2001 >From: Jianglei Nie <niejianglei2021@163.com> >Date: Thu, 7 Jul 2022 14:18:15 +0800 >Subject: [PATCH] ext2fs: fix potential memory leak in ext4_ext_grow_indepth() > >ext4_ext_grow_indepth() allocates memory chunk for "newblk" with >ext4_ext_alloc_meta(). When getblk() and bwrite() fail in this funciton, >"newblk" is not released, which will lead to a memory leak. > >We should release the "newblk" with ext4_ext_blkfree() when some error >occurs to avoid the memory leak. > >Signed-off-by: Jianglei Nie <niejianglei2021@163.com> >--- > 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; > >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 265071
: 235103