Skip to contentSkip to conversation

opensm/osm_db_files.c: fix small memory leak

PATCH Applied Yevgeny Kliteynik 2 participants 3 messages Sep 7, 2010 – Sep 9, 2010 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm/osm_db_files.c: fix small memory leak

---
 opensm/opensm/osm_db_files.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
opensm/opensm/osm_db_files.c +1 -0
index c475004..603bcf2 100644
@@ -175,6 +175,7 @@ int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log)
 			OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6101: "
 				"Failed to create the db directory:%s\n",
 				p_db_imp->db_dir_name);
+			free(p_db_imp);
 			OSM_LOG_EXIT(p_log);
 			return 1;
 		}
Signature · 6 lines
1.6.2.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4C8654C0.7020208-VPRAkNaXOzVS1MOuV/[email protected]

#3 lore raw

PATCH 1/1 opensm/osm_db_files.c: malloc() return value run-time check

In reply to a message not in the archive

Check a return value of malloc() run-time instead of debug macro.

---
 opensm/opensm/osm_db_files.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
opensm/opensm/osm_db_files.c +4 -1
index 07a9ce0..18ac830 100644
@@ -157,7 +157,10 @@ int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log)
 	OSM_LOG_ENTER(p_log);
 
 	p_db_imp = malloc(sizeof(osm_db_imp_t));
-	CL_ASSERT(p_db_imp != NULL);
+	if (!p_db_imp) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6100: No memory.\n");
+		return -1;
+	}
 
 	p_db_imp->db_dir_name = getenv("OSM_CACHE_DIR");
 	if (!p_db_imp->db_dir_name || !(*p_db_imp->db_dir_name))
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html