[ofa-general] [PATCHv3] opensm/osm_perfmgr_db.c: Fix memory leak of db nodes
Hal Rosenstock
hnrose at comcast.net
Mon Sep 21 07:44:31 PDT 2009
Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
Changes since v2:
Eliminated node variable
Changes since v1:
Fix use after free issue
diff --git a/opensm/opensm/osm_perfmgr_db.c b/opensm/opensm/osm_perfmgr_db.c
index e5dfc19..5321c59 100644
--- a/opensm/opensm/osm_perfmgr_db.c
+++ b/opensm/opensm/osm_perfmgr_db.c
@@ -49,6 +49,8 @@
#include <opensm/osm_perfmgr.h>
#include <opensm/osm_opensm.h>
+static void free_node(db_node_t * node);
+
/** =========================================================================
*/
perfmgr_db_t *perfmgr_db_construct(osm_perfmgr_t *perfmgr)
@@ -68,7 +70,15 @@ perfmgr_db_t *perfmgr_db_construct(osm_perfmgr_t *perfmgr)
*/
void perfmgr_db_destroy(perfmgr_db_t * db)
{
+ cl_map_item_t *item, *next_item;
+
if (db) {
+ item = cl_qmap_head(&db->pc_data);
+ while (item != cl_qmap_end(&db->pc_data)) {
+ next_item = cl_qmap_next(item);
+ free_node((db_node_t *)item);
+ item = next_item;
+ }
cl_plock_destroy(&db->lock);
free(db);
}
More information about the general
mailing list