[openib-general] [PATCH] opensm: fix segfault with up/down and root nodes file.

Sasha Khapyorsky sashak at voltaire.com
Tue Jan 9 15:21:29 PST 2007


Segfault happens when yet non-initialized lid_matrix tables are
accessed - with up/down routing engine when root nodes are provided by
user and lid matrices are not pre-created. There is the fix.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/include/opensm/osm_matrix.h |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/osm/include/opensm/osm_matrix.h b/osm/include/opensm/osm_matrix.h
index 9a940be..bf28e83 100644
--- a/osm/include/opensm/osm_matrix.h
+++ b/osm/include/opensm/osm_matrix.h
@@ -236,7 +236,10 @@ osm_lid_matrix_get(
 	IN const uint8_t port_num )
 {
 	CL_ASSERT( port_num < p_lmx->num_ports );
-	CL_ASSERT( lid_ho <cl_vector_get_size(&p_lmx->lid_vec) );
+
+	if ( lid_ho >= cl_vector_get_size(&p_lmx->lid_vec) )
+		return OSM_NO_PATH;
+
 	return( ((uint8_t *)cl_vector_get_ptr(
 			&p_lmx->lid_vec, lid_ho ))[port_num] );
 }
@@ -273,7 +276,8 @@ static inline uint16_t
 osm_lid_matrix_get_max_lid_ho(
 	IN const osm_lid_matrix_t* const p_lmx )
 {
-	return( (uint16_t)(cl_vector_get_size( &p_lmx->lid_vec ) - 1 ) );
+	return cl_vector_get_size( &p_lmx->lid_vec ) ?
+		(uint16_t)(cl_vector_get_size( &p_lmx->lid_vec ) - 1) : 0;
 }
 /*
 * PARAMETERS
-- 
1.4.4.2.gfc82d





More information about the general mailing list