aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhanchengbin <zhanchengbin1@huawei.com>2021-12-31 15:43:36 +0800
committerTheodore Ts'o <tytso@mit.edu>2022-05-11 20:56:42 -0400
commit1c966c9dffef7e823a020a2f3982e9b9b1953e8b (patch)
tree610beb13df94903e9e65aeb8c9d0d5528d4cf4a1
parentfdec633fd661e79b7b81e848b5699775328d70ae (diff)
downloade2fsprogs-1c966c9dffef7e823a020a2f3982e9b9b1953e8b.tar.gz
libext2fs: fix memory leak in error path while opening test_io manager
Link: https://lore.kernel.org/r/d0632bbc-9713-38a9-c914-137b702f6ae1@huawei.com Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/test_io.c2
-rw-r--r--lib/ext2fs/undo_io.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index 480e68fcc..6843edbcf 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -248,6 +248,8 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
return 0;
cleanup:
+ if (io && io->name)
+ ext2fs_free_mem(&io->name);
if (io)
ext2fs_free_mem(&io);
if (data)
diff --git a/lib/ext2fs/undo_io.c b/lib/ext2fs/undo_io.c
index eb56f53d5..f4a6d5267 100644
--- a/lib/ext2fs/undo_io.c
+++ b/lib/ext2fs/undo_io.c
@@ -790,6 +790,8 @@ cleanup:
io_channel_close(data->real);
if (data)
ext2fs_free_mem(&data);
+ if (io && io->name)
+ ext2fs_free_mem(&io->name);
if (io)
ext2fs_free_mem(&io);
return retval;