Blame SOURCES/0002-resource-manager-rm-ref-count-inc-of-handle_entry.patch

1a1093
From ec7116d0e4de535a90c1dc5edabe821f04a0f8e0 Mon Sep 17 00:00:00 2001
1a1093
From: William Roberts <william.c.roberts@intel.com>
1a1093
Date: Wed, 13 Jan 2021 12:21:47 -0600
1a1093
Subject: [PATCH 2/6] resource-manager: rm ref count inc of handle_entry
1a1093
1a1093
Per:
1a1093
  - https://developer.gnome.org/gobject/stable/gobject-memory.html
1a1093
1a1093
g_object_new sets the ref count to 1, so their is no need to bump it
1a1093
again, we already have ownership.
1a1093
1a1093
Fixes leaks like:
1a1093
Direct leak of 10480 byte(s) in 2 object(s) allocated from:
1a1093
    #0 0x7f1aa88aabc8 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
1a1093
    #1 0x7f1aa848acd8 in g_malloc (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x57cd8)
1a1093
    #2 0x7f1aa84a32c5 in g_slice_alloc (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x702c5)
1a1093
    #3 0x7f1aa84a38ed in g_slice_alloc0 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x708ed)
1a1093
    #4 0x7f1aa85970cf in g_type_create_instance (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x3b0cf)
1a1093
    #5 0x7f1aa857634c  (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x1a34c)
1a1093
    #6 0x7f1aa8578377 in g_object_new_valist (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x1c377)
1a1093
    #7 0x7f1aa85786cc in g_object_new (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x1c6cc)
1a1093
    #8 0x561e13d667d3 in handle_map_entry_new src/handle-map-entry.c:138
1a1093
    #9 0x561e13d540d3 in create_context_mapping_transient src/resource-manager.c:1160
1a1093
    #10 0x561e13d547b1 in resource_manager_create_context_mapping src/resource-manager.c:1261
1a1093
    #11 0x561e13d54ec8 in resource_manager_process_tpm2_command src/resource-manager.c:1359
1a1093
    #12 0x561e13d55365 in resource_manager_thread src/resource-manager.c:1424
1a1093
    #13 0x7f1aa8384608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
1a1093
    #14 0x7f1aa82ab292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
1a1093
1a1093
Signed-off-by: William Roberts <william.c.roberts@intel.com>
1a1093
---
1a1093
 src/resource-manager.c | 1 -
1a1093
 1 file changed, 1 deletion(-)
1a1093
1a1093
diff --git a/src/resource-manager.c b/src/resource-manager.c
1a1093
index 904f683..050436f 100644
1a1093
--- a/src/resource-manager.c
1a1093
+++ b/src/resource-manager.c
1a1093
@@ -1167,7 +1167,6 @@ create_context_mapping_transient (ResourceManager  *resmgr,
1a1093
     handle_map_insert (handle_map, vhandle, handle_entry);
1a1093
     g_object_unref (handle_map);
1a1093
     tpm2_response_set_handle (response, vhandle);
1a1093
-    g_object_ref (handle_entry);
1a1093
 }
1a1093
 /*
1a1093
  * This function after a Tpm2Command is sent to the TPM and:
1a1093
-- 
1a1093
2.34.3
1a1093