diff mbox

[1/2,opensm] osm_link_mgr.c: fix uninitialized variable usage

Message ID 52813CBE.40203@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock Nov. 11, 2013, 8:23 p.m. UTC
From: Alex Netes <alexne@mellanox.com>

PortInfo may be sent without the correct M_Key

Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_link_mgr.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c
index 2420e4f..5fdb7ca 100644
--- a/opensm/osm_link_mgr.c
+++ b/opensm/osm_link_mgr.c
@@ -149,6 +149,8 @@  static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
 			goto Exit;
 		}
 
+		physp0 = osm_node_get_physp_ptr(p_physp->p_node, 0);
+
 		if (ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info)
 		    == FALSE) {
 
@@ -190,6 +192,13 @@  static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
 	p_pi->state_info2 = 0x02;
 	ib_port_info_set_port_state(p_pi, port_state);
 
+	/* Determine ports' M_Key */
+	if (osm_node_get_type(p_physp->p_node) == IB_NODE_TYPE_SWITCH &&
+	    osm_physp_get_port_num(p_physp) != 0)
+		m_key = ib_port_info_get_m_key(&physp0->port_info);
+	else
+		m_key = ib_port_info_get_m_key(p_pi);
+
 	/* Check whether this is base port0 smsl handling only */
 	if (port_num == 0 && esp0 == FALSE) {
 		ib_port_info_set_master_smsl(p_pi, smsl);
@@ -369,13 +378,10 @@  static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
 
 		if (osm_node_get_type(p_physp->p_node) == IB_NODE_TYPE_SWITCH &&
 		    osm_physp_get_port_num(p_physp) != 0) {
-			physp0 = osm_node_get_physp_ptr(p_physp->p_node, 0);
 			cap_mask = physp0->port_info.capability_mask;
-			m_key = ib_port_info_get_m_key(&physp0->port_info);
-		} else {
+		} else
 			cap_mask = p_pi->capability_mask;
-			m_key = ib_port_info_get_m_key(p_pi);
-		}
+
 		if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
 			issue_ext = 1;