From patchwork Mon Nov 11 20:23:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 3169731 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E2695C045B for ; Mon, 11 Nov 2013 20:24:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A71E20387 for ; Mon, 11 Nov 2013 20:24:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0073F203F3 for ; Mon, 11 Nov 2013 20:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751007Ab3KKUYO (ORCPT ); Mon, 11 Nov 2013 15:24:14 -0500 Received: from mail-ea0-f170.google.com ([209.85.215.170]:53005 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752127Ab3KKUXc (ORCPT ); Mon, 11 Nov 2013 15:23:32 -0500 Received: by mail-ea0-f170.google.com with SMTP id q10so2516612eaj.1 for ; Mon, 11 Nov 2013 12:23:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:content-type:content-transfer-encoding; bh=fgVBSDbURD3X7pWoQfklAH4vQVqEBCrSsKq7UntGCik=; b=UiEGA9mjP6iJLFPi1pqbGM2HLOH1TaaVxyUXb7OQtdm9hKk3BtAGKlB+GHaCYkK3mk fjdRnckYh1VyqkE6SsnH4l1sYNNctL+BRf84ENy9421gOmXyoW0PLrVAPVk5mLHY1OJV 5qx4diik2pvug3tS2xNWQL01xPV0d8dA6r11XytJ9wsBpluB/U3tsusb4i5gxlrrEzww hcvfjrrFhgOprsUqlWvkhc3i0Z81Vgj4FljifFSbgF0ahx6vtXGfQglSyG0cqgCIKiPc 35OtBVtIp/0HS64lkvsnE/DyNBfHo42q/G9+p6oGRayfw/Nc4O2zDY5H0xB5g2i79iGy j8Iw== X-Gm-Message-State: ALoCoQmLalOz/npdDFMrcs+J0C9wHLrR3NoEo4NJa8SgWhVdLmF3I945oPfuGVfwOgFTBMjWXA/d X-Received: by 10.14.42.6 with SMTP id i6mr4384968eeb.65.1384201410415; Mon, 11 Nov 2013 12:23:30 -0800 (PST) Received: from [192.168.1.102] (c-98-229-118-119.hsd1.ma.comcast.net. [98.229.118.119]) by mx.google.com with ESMTPSA id h8sm67084615eew.16.2013.11.11.12.23.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Nov 2013 12:23:30 -0800 (PST) Message-ID: <52813CBE.40203@dev.mellanox.co.il> Date: Mon, 11 Nov 2013 15:23:26 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: "linux-rdma (linux-rdma@vger.kernel.org)" CC: Alex Netes Subject: [PATCH 1/2 opensm] osm_link_mgr.c: fix uninitialized variable usage Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alex Netes PortInfo may be sent without the correct M_Key Signed-off-by: Alex Netes Signed-off-by: Hal Rosenstock --- opensm/osm_link_mgr.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) 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;