1From 1c966c9dffef7e823a020a2f3982e9b9b1953e8b Mon Sep 17 00:00:00 2001
2From: zhanchengbin <zhanchengbin1@huawei.com>
3Date: Fri, 31 Dec 2021 15:43:36 +0800
4Subject: libext2fs: fix memory leak in error path while opening test_io
5 manager
6
7Link: https://lore.kernel.org/r/d0632bbc-9713-38a9-c914-137b702f6ae1@huawei.com
8Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
9Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10---
11 lib/ext2fs/test_io.c | 2 ++
12 lib/ext2fs/undo_io.c | 2 ++
13 2 files changed, 4 insertions(+)
14
15diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
16index 480e68fc..6843edbc 100644
17--- a/lib/ext2fs/test_io.c
18+++ b/lib/ext2fs/test_io.c
19@@ -248,6 +248,8 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
20 	return 0;
21 
22 cleanup:
23+	if (io && io->name)
24+		ext2fs_free_mem(&io->name);
25 	if (io)
26 		ext2fs_free_mem(&io);
27 	if (data)
28diff --git a/lib/ext2fs/undo_io.c b/lib/ext2fs/undo_io.c
29index eb56f53d..f4a6d526 100644
30--- a/lib/ext2fs/undo_io.c
31+++ b/lib/ext2fs/undo_io.c
32@@ -790,6 +790,8 @@ cleanup:
33 		io_channel_close(data->real);
34 	if (data)
35 		ext2fs_free_mem(&data);
36+	if (io && io->name)
37+		ext2fs_free_mem(&io->name);
38 	if (io)
39 		ext2fs_free_mem(&io);
40 	return retval;
41-- 
42cgit 
43
44