[ofa-general] [PATCH] opensm: fix potential core dumps

Sasha Khapyorsky sashak at voltaire.com
Thu Feb 21 13:06:37 PST 2008


When for some reason one or more PortInfo was dropped switch node may
have uninitialized elements in physp_table array and
osm_node_get_physp_ptr() will return NULL.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---

This patch is not related to OFED.

 opensm/opensm/osm_perfmgr.c   |    2 +-
 opensm/opensm/osm_state_mgr.c |    2 +-
 opensm/opensm/osm_ucast_mgr.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index c1c620c..cc95bee 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -629,7 +629,7 @@ static int sweep_hop_1(osm_sm_t * sm)
 		for (port_num = 0; port_num < num_ports; port_num++) {
 			/* go through the port only if the port is not DOWN */
 			p_ext_physp = osm_node_get_physp_ptr(p_node, port_num);
-			if (ib_port_info_get_port_state
+			if (!p_ext_physp || ib_port_info_get_port_state
 			    (&p_ext_physp->port_info) <= IB_LINK_DOWN)
 				continue;
 
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 8f76c00..38b2c4e 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -504,7 +504,7 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_sm_t * sm)
 		for (port_num = 0; port_num < num_ports; port_num++) {
 			/* go through the port only if the port is not DOWN */
 			p_ext_physp = osm_node_get_physp_ptr(p_node, port_num);
-			if (ib_port_info_get_port_state
+			if (p_ext_physp && ib_port_info_get_port_state
 			    (&(p_ext_physp->port_info)) > IB_LINK_DOWN) {
 				memset(&context, 0, sizeof(context));
 				context.ni_context.node_guid =
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index 27a206f..1aa5ea9 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -561,7 +561,7 @@ __osm_ucast_mgr_process_neighbors(IN cl_map_item_t * const p_map_item,
 			/* make sure the link is healthy. If it is not - don't
 			   propagate through it. */
 			p_physp = osm_node_get_physp_ptr(p_node, port_num);
-			if (!osm_link_is_healthy(p_physp))
+			if (!p_physp || !osm_link_is_healthy(p_physp))
 				continue;
 
 			__osm_ucast_mgr_process_neighbor(p_mgr, p_sw,
-- 
1.5.4.1.122.gaa8d




More information about the general mailing list