diff mbox

[2/2] opensm/osm_torus.c: Handle calloc() failure on routing engine context creation.

Message ID 1284742994-24503-3-git-send-email-jaschut@sandia.gov (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Jim Schutt Sept. 17, 2010, 5:03 p.m. UTC
None
diff mbox

Patch

diff --git a/opensm/opensm/osm_torus.c b/opensm/opensm/osm_torus.c
index 12b480d..3b67f16 100644
--- a/opensm/opensm/osm_torus.c
+++ b/opensm/opensm/osm_torus.c
@@ -410,7 +410,11 @@  struct torus_context *torus_context_create(osm_opensm_t *osm)
 	struct torus_context *ctx;
 
 	ctx = calloc(1, sizeof(*ctx));
-	ctx->osm = osm;
+	if (ctx)
+		ctx->osm = osm;
+	else
+		OSM_LOG(&osm->log, OSM_LOG_ERROR,
+			"Error: calloc: %s\n", strerror(errno));
 
 	return ctx;
 }
@@ -9113,6 +9117,8 @@  int osm_ucast_torus2QoS_setup(struct osm_routing_engine *r,
 	struct torus_context *ctx;
 
 	ctx = torus_context_create(osm);
+	if (!ctx)
+		return -1;
 
 	r->context = ctx;
 	r->ucast_build_fwd_tables = torus_build_lfts;