|
|
1a1093 |
From 62ae28635ada2a74b526244e8ea69cef74c6c022 Mon Sep 17 00:00:00 2001
|
|
|
1a1093 |
From: William Roberts <william.c.roberts@intel.com>
|
|
|
1a1093 |
Date: Wed, 13 Jan 2021 13:52:06 -0600
|
|
|
1a1093 |
Subject: [PATCH 3/6] tabrmd-init.c: fix leaks on main to thread tpm2 instance
|
|
|
1a1093 |
|
|
|
1a1093 |
Theirs a case where the Tpm2 object coming in from main to the thread
|
|
|
1a1093 |
fails setup and the cleanup function doesn't unref it. Move it to the
|
|
|
1a1093 |
main cleanup routine and use g_clear_object to be *clear* on whom owns
|
|
|
1a1093 |
the reference.
|
|
|
1a1093 |
|
|
|
1a1093 |
Fixes leaks like:
|
|
|
1a1093 |
Indirect leak of 4176 byte(s) in 1 object(s) allocated from:
|
|
|
1a1093 |
#0 0x7f652e71cdc6 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10ddc6)
|
|
|
1a1093 |
#1 0x7f652e25ad30 in g_malloc0 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57d30)
|
|
|
1a1093 |
#2 0x555ebb1a1c5f in sapi_context_init src/tpm2.c:162
|
|
|
1a1093 |
#3 0x555ebb1a2fa8 in tpm2_new src/tpm2.c:438
|
|
|
1a1093 |
#4 0x555ebb19d665 in init_thread_func src/tabrmd-init.c:178
|
|
|
1a1093 |
#5 0x555ebb19bede in init_thread_func_tpm2_init_fail test/tabrmd-init_unit.c:199
|
|
|
1a1093 |
#6 0x7f652e6074e0 (/usr/lib/x86_64-linux-gnu/libcmocka.so.0+0x54e0)
|
|
|
1a1093 |
|
|
|
1a1093 |
Signed-off-by: William Roberts <william.c.roberts@intel.com>
|
|
|
1a1093 |
---
|
|
|
1a1093 |
src/tabrmd-init.c | 5 ++++-
|
|
|
1a1093 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
1a1093 |
|
|
|
1a1093 |
diff --git a/src/tabrmd-init.c b/src/tabrmd-init.c
|
|
|
1a1093 |
index 58e0103..866c852 100644
|
|
|
1a1093 |
--- a/src/tabrmd-init.c
|
|
|
1a1093 |
+++ b/src/tabrmd-init.c
|
|
|
1a1093 |
@@ -99,6 +99,9 @@ gmain_data_cleanup (gmain_data_t *data)
|
|
|
1a1093 |
if (data->loop != NULL) {
|
|
|
1a1093 |
main_loop_quit (data->loop);
|
|
|
1a1093 |
}
|
|
|
1a1093 |
+ if (data->tpm2) {
|
|
|
1a1093 |
+ g_clear_object (&data->tpm2);
|
|
|
1a1093 |
+ }
|
|
|
1a1093 |
|
|
|
1a1093 |
tabrmd_options_free(&data->options);
|
|
|
1a1093 |
}
|
|
|
1a1093 |
@@ -208,7 +211,7 @@ init_thread_func (gpointer user_data)
|
|
|
1a1093 |
g_clear_object (&session_list);
|
|
|
1a1093 |
data->response_sink = response_sink_new ();
|
|
|
1a1093 |
g_object_unref (command_attrs);
|
|
|
1a1093 |
- g_object_unref (data->tpm2);
|
|
|
1a1093 |
+ g_clear_object (&data->tpm2);
|
|
|
1a1093 |
/*
|
|
|
1a1093 |
* Wire up the TPM command processing pipeline. TPM command buffers
|
|
|
1a1093 |
* flow from the CommandSource, to the Tab then finally back to the
|
|
|
1a1093 |
--
|
|
|
1a1093 |
2.34.3
|
|
|
1a1093 |
|