[ofa-general] [PATCH] opensm/libvendor/osm_vendor_(ibumad mlx)_sa.c: Handle malloc failure in __osmv_send_sa_req

Hal Rosenstock hnrose at comcast.net
Thu Jun 25 05:53:16 PDT 2009


Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/libvendor/osm_vendor_ibumad_sa.c b/opensm/libvendor/osm_vendor_ibumad_sa.c
index 218cce2..24146a7 100644
--- a/opensm/libvendor/osm_vendor_ibumad_sa.c
+++ b/opensm/libvendor/osm_vendor_ibumad_sa.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -437,6 +438,13 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
 	   p_madw->context.ni_context.node_guid
 	 */
 	p_query_req_copy = malloc(sizeof(*p_query_req_copy));
+	if (!p_query_req_copy) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5511: "
+			"Unable to acquire memory for query copy\n");
+		osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+		status = IB_INSUFFICIENT_RESOURCES;
+		goto Exit;
+	}
 	*p_query_req_copy = *p_query_req;
 	p_madw->context.ni_context.node_guid =
 	    (ib_net64_t) (long)p_query_req_copy;
diff --git a/opensm/libvendor/osm_vendor_mlx_sa.c b/opensm/libvendor/osm_vendor_mlx_sa.c
index 7bd5aea..23e16ea 100644
--- a/opensm/libvendor/osm_vendor_mlx_sa.c
+++ b/opensm/libvendor/osm_vendor_mlx_sa.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -552,6 +553,13 @@ __osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
 	   p_madw->context.arb_context.context1
 	 */
 	p_query_req_copy = malloc(sizeof(*p_query_req_copy));
+	if (!p_query_req_copy) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0511: "
+			"Unable to acquire memory for query copy\n");
+		osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+		status = IB_INSUFFICIENT_RESOURCES;
+		goto Exit;
+	}
 	*p_query_req_copy = *p_query_req;
 	p_madw->context.arb_context.context1 = p_query_req_copy;
 



More information about the general mailing list