[PATCH 08/15] libext2fs: fix memory leak on error path

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Namhyung Kim
Date: Monday, November 29, 2010 - 1:55 am

io->name should be freed if ext2fs_file_open2() fails.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 lib/ext2fs/inode_io.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/ext2fs/inode_io.c b/lib/ext2fs/inode_io.c
index 4faaa48..bc934d3 100644
--- a/lib/ext2fs/inode_io.c
+++ b/lib/ext2fs/inode_io.c
@@ -157,11 +157,13 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel)
 				   &data->inode : 0, open_flags,
 				   &data->file);
 	if (retval)
-		goto cleanup;
+		goto cleanup_name;
 
 	*channel = io;
 	return 0;
 
+cleanup_name:
+	ext2fs_free_mem(&io->name);
 cleanup:
 	if (data) {
 		ext2fs_free_mem(&data);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/15] e2fsprogs cleanups, Namhyung Kim, (Mon Nov 29, 1:55 am)
[PATCH 08/15] libext2fs: fix memory leak on error path, Namhyung Kim, (Mon Nov 29, 1:55 am)
[PATCH 11/15] mke2fs: fix determination of size_type, Namhyung Kim, (Mon Nov 29, 1:55 am)
[PATCH 12/15] mke2fs: add some error checks into PRS(), Namhyung Kim, (Mon Nov 29, 1:55 am)
[PATCH 15/15] mke2fs.8.in: add ENVIRONMENT section, Namhyung Kim, (Mon Nov 29, 1:55 am)
Re: [PATCH 11/15] mke2fs: fix determination of size_type, Lukas Czerner, (Tue Nov 30, 5:33 am)