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

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