OpenSM: trivial fix for segfault on invalid port info
authoreitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 4 Apr 2006 08:53:53 +0000 (08:53 +0000)
committereitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 4 Apr 2006 08:53:53 +0000 (08:53 +0000)
A previous patch adding explicit set remote port state DOWN in case the
local one is recycled was not safe. In the case of irresponsive remote
port, it would actually try and traverse a null pointer of the port info.

This simple fix is just a little more careful about it.
p_rem_port was also renamed to p_rem_physp as the pointer actually
points to a physical port...

Signed-off-by: Eitan Zahavi <eitan@mellanox.co.il>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@279 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/opensm/user/opensm/osm_lid_mgr.c

index 2f0752f..22b3a53 100644 (file)
@@ -917,13 +917,18 @@ __osm_lid_mgr_set_remote_pi_state_to_init(
   IN osm_physp_t*          const p_physp)
 {
   ib_port_info_t *p_pi;
-  osm_physp_t *p_rem_port = osm_physp_get_remote(p_physp);
+  osm_physp_t *p_rem_physp = osm_physp_get_remote(p_physp);
 
-  CL_ASSERT(p_rem_port);
+  CL_ASSERT(p_rem_physp);
 
-  p_pi = osm_physp_get_port_info_ptr( p_rem_port );
+  if (osm_physp_is_valid( p_rem_physp ))
+  {
+    p_pi = osm_physp_get_port_info_ptr( p_rem_physp );
+    /* but in some rare cases the remote side might be irresponsive  */
+    if (p_pi)
   ib_port_info_set_port_state( p_pi, IB_LINK_INIT );
 }
+}
 
 /**********************************************************************
  **********************************************************************/