diff mbox series

[v2,02/12] tdb_transaction_recover: fix memory leak

Message ID 20210630082724.50838-3-wuguanghao3@huawei.com
State Accepted
Headers show
Series [v2,01/12] profile_create_node: set magic before strdup(name) to avoid memory leak | expand

Commit Message

wuguanghao June 30, 2021, 8:27 a.m. UTC
In tdb_transaction_recover(), need free data before return,
otherwise it will cause memory leak.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
---
 lib/ext2fs/tdb.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Theodore Ts'o July 16, 2021, 3:19 a.m. UTC | #1
On Wed, Jun 30, 2021 at 04:27:14PM +0800, wuguanghao wrote:
> In tdb_transaction_recover(), need free data before return,
> otherwise it will cause memory leak.
> 
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Reviewed-by: Wu Bo <wubo40@huawei.com>

Thanks, applied.

				- Ted
diff mbox series

Patch

diff --git a/lib/ext2fs/tdb.c b/lib/ext2fs/tdb.c
index 5091b128..0fb94815 100644
--- a/lib/ext2fs/tdb.c
+++ b/lib/ext2fs/tdb.c
@@ -2186,6 +2186,7 @@  int tdb_transaction_recover(struct tdb_context *tdb)
 				   rec.data_len, 0) == -1) {
 		TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n"));
 		tdb->ecode = TDB_ERR_IO;
+		free(data);
 		return -1;
 	}