2007-04-05 00:30:46

by Jim Garlick

[permalink] [raw]
Subject: [PATCH] libext2fs memory leak in ext2fs_write_new_inode()

The following patch addresses a memory leak in libext2fs
that occurs when using ext2fs_write_new_inode() on a file system
configured with large inodes.

Signed-off-by: Jim Garlick <[email protected]>

Index: e2fsprogs+chaos/lib/ext2fs/inode.c
===================================================================
--- e2fsprogs+chaos.orig/lib/ext2fs/inode.c
+++ e2fsprogs+chaos/lib/ext2fs/inode.c
@@ -752,6 +752,7 @@ errcode_t ext2fs_write_new_inode(ext2_fi
struct ext2_inode *buf;
int size = EXT2_INODE_SIZE(fs->super);
struct ext2_inode_large *large_inode;
+ errcode_t rc;

if (size == sizeof(struct ext2_inode))
return ext2fs_write_inode_full(fs, ino, inode,
@@ -768,7 +769,9 @@ errcode_t ext2fs_write_new_inode(ext2_fi
large_inode->i_extra_isize = sizeof(struct ext2_inode_large) -
EXT2_GOOD_OLD_INODE_SIZE;

- return ext2fs_write_inode_full(fs, ino, buf, size);
+ rc = ext2fs_write_inode_full(fs, ino, buf, size);
+ free(buf);
+ return rc;
}


2007-04-06 12:53:29

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] libext2fs memory leak in ext2fs_write_new_inode()

On Wed, Apr 04, 2007 at 05:21:05PM -0700, Jim Garlick wrote:
> The following patch addresses a memory leak in libext2fs
> that occurs when using ext2fs_write_new_inode() on a file system
> configured with large inodes.
>
> Signed-off-by: Jim Garlick <[email protected]>

Thanks for this patch! I've committed into the e2fsprogs hg source
code repository, and it will be in the next release of e2fsprogs.

- Ted