[ofa-general] [PATCH] opensm/osm_perfmgr_db.c: Fix memory leak of db nodes

Hal Rosenstock hnrose at comcast.net
Fri Sep 18 07:31:28 PDT 2009


Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/opensm/osm_perfmgr_db.c b/opensm/opensm/osm_perfmgr_db.c
index e5dfc19..329743a 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,16 @@ perfmgr_db_t *perfmgr_db_construct(osm_perfmgr_t *perfmgr)
  */
 void perfmgr_db_destroy(perfmgr_db_t * db)
 {
+	cl_map_item_t *item;
+	db_node_t *node;
+
 	if (db) {
+		item = cl_qmap_head(&db->pc_data);
+		while (item != cl_qmap_end(&db->pc_data)) {
+			node = (db_node_t *)item;
+			free_node(node);
+			item = cl_qmap_next(item);
+		}
 		cl_plock_destroy(&db->lock);
 		free(db);
 	}



More information about the general mailing list