From patchwork Wed Feb 20 19:02:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 2168801 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E66AC3FD4E for ; Wed, 20 Feb 2013 19:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934598Ab3BTTCh (ORCPT ); Wed, 20 Feb 2013 14:02:37 -0500 Received: from mail-ia0-f172.google.com ([209.85.210.172]:64490 "EHLO mail-ia0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933973Ab3BTTCh (ORCPT ); Wed, 20 Feb 2013 14:02:37 -0500 Received: by mail-ia0-f172.google.com with SMTP id l29so5391416iag.17 for ; Wed, 20 Feb 2013 11:02:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=uyWCi5q49mJ8fFSzAGFqJv3tlHoxHvgnuYsfC1rlHZc=; b=cyxGJcdZ7AMMgiOlB1Gpx3oBXvVItdvUXnuUrTI3Xruge/AhQS4MUKNZRMb49ZGwQT xcMcvuiTuBIiF31QGIB11XE+GLFeyBQq9YJj1orBuzRS9j0GQtk+NvPIILzfKYhWWs6R w/n90ji9vDiFabgjbkMt+Y33iV4xEE/1b4qBPpIT1qnLlhUrHDRcX50WnuvlzJMthAbE tZhMt41rDEiUnRoWHgTKFN75RsTATTYTRndM1pAr3WCg1buwK7ZifHCFT3bnLLCTkwKK jgkJzGXRWuQOwUln+uFaKGLIlUcDVQKn21gWMz0NH4MsOJI6TgENEE7uDPl//KD5P4PP Wmyg== X-Received: by 10.42.54.5 with SMTP id p5mr9727086icg.49.1361386956452; Wed, 20 Feb 2013 11:02:36 -0800 (PST) Received: from [192.168.1.102] (c-71-234-225-85.hsd1.ct.comcast.net. [71.234.225.85]) by mx.google.com with ESMTPS id ee5sm8490134igc.0.2013.02.20.11.02.34 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Feb 2013 11:02:35 -0800 (PST) Message-ID: <51251DC9.6030407@dev.mellanox.co.il> Date: Wed, 20 Feb 2013 14:02:33 -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)" Subject: [PATCH] opensm/osm_sa_multipath_record.c: Fix seg fault in mpr_rcv_get_apm_paths X-Gm-Message-State: ALoCoQmh151Xk3ilGNYM+y3JBGRShl/8icPEsWZT1fU9ixrYmp2KY6B3aUA4736R+wPvi4l+5jPd Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org When routing fails, mpr_rcv_get_apm_port_pair_paths returns NULL and this is not handled in mpr_rcv_get_apm_paths Signed-off-by: Hal Rosenstock --- -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/opensm/osm_sa_multipath_record.c b/opensm/osm_sa_multipath_record.c index 03ffd47..9153a58 100644 --- a/opensm/osm_sa_multipath_record.c +++ b/opensm/osm_sa_multipath_record.c @@ -1415,26 +1415,46 @@ static void mpr_rcv_get_apm_paths(IN osm_sa_t * sa, OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "APM matrix:\n" "\t{0,0} 0x%X->0x%X (%d)\t| {0,1} 0x%X->0x%X (%d)\n" "\t{1,0} 0x%X->0x%X (%d)\t| {1,1} 0x%X->0x%X (%d)\n", - matrix[0][0]->resp.mpr_rec.path_rec.slid, - matrix[0][0]->resp.mpr_rec.path_rec.dlid, - matrix[0][0]->resp.mpr_rec.hops, - matrix[0][1]->resp.mpr_rec.path_rec.slid, - matrix[0][1]->resp.mpr_rec.path_rec.dlid, - matrix[0][1]->resp.mpr_rec.hops, - matrix[1][0]->resp.mpr_rec.path_rec.slid, - matrix[1][0]->resp.mpr_rec.path_rec.dlid, - matrix[1][0]->resp.mpr_rec.hops, - matrix[1][1]->resp.mpr_rec.path_rec.slid, - matrix[1][1]->resp.mpr_rec.path_rec.dlid, - matrix[1][1]->resp.mpr_rec.hops); + matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.slid : 0, + matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.dlid : 0, + matrix[0][0] ? matrix[0][0]->resp.mpr_rec.hops : 0, + matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.slid : 0, + matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.dlid : 0, + matrix[0][1] ? matrix[0][1]->resp.mpr_rec.hops : 0, + matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.slid : 0, + matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.dlid : 0, + matrix[1][0] ? matrix[1][0]->resp.mpr_rec.hops : 0, + matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.slid : 0, + matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.dlid : 0, + matrix[1][1] ? matrix[1][1]->resp.mpr_rec.hops : 0); + + sumA = minA = sumB = minB = 0; /* check diagonal A {(0,0), (1,1)} */ - sumA = matrix[0][0]->resp.mpr_rec.hops + matrix[1][1]->resp.mpr_rec.hops; - minA = min(matrix[0][0]->resp.mpr_rec.hops, matrix[1][1]->resp.mpr_rec.hops); + if (matrix[0][0]) { + sumA += matrix[0][0]->resp.mpr_rec.hops; + minA = matrix[0][0]->resp.mpr_rec.hops; + } + if (matrix[1][1]) { + sumA += matrix[1][1]->resp.mpr_rec.hops; + if (minA) + minA = min(minA, matrix[1][1]->resp.mpr_rec.hops); + else + minA = matrix[1][1]->resp.mpr_rec.hops; + } /* check diagonal B {(0,1), (1,0)} */ - sumB = matrix[0][1]->resp.mpr_rec.hops + matrix[1][0]->resp.mpr_rec.hops; - minB = min(matrix[0][1]->resp.mpr_rec.hops, matrix[1][0]->resp.mpr_rec.hops); + if (matrix[0][1]) { + sumB += matrix[0][1]->resp.mpr_rec.hops; + minB = matrix[0][1]->resp.mpr_rec.hops; + } + if (matrix[1][0]) { + sumB += matrix[1][0]->resp.mpr_rec.hops; + if (minB) + minB = min(minB, matrix[1][0]->resp.mpr_rec.hops); + else + minB = matrix[1][0]->resp.mpr_rec.hops; + } /* and the winner is... */ if (minA <= minB || (minA == minB && sumA < sumB)) { @@ -1442,14 +1462,16 @@ static void mpr_rcv_get_apm_paths(IN osm_sa_t * sa, OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Diag {0,0} & {1,1} is the best:\n" "\t{0,0} 0x%X->0x%X (%d)\t & {1,1} 0x%X->0x%X (%d)\n", - matrix[0][0]->resp.mpr_rec.path_rec.slid, - matrix[0][0]->resp.mpr_rec.path_rec.dlid, - matrix[0][0]->resp.mpr_rec.hops, - matrix[1][1]->resp.mpr_rec.path_rec.slid, - matrix[1][1]->resp.mpr_rec.path_rec.dlid, - matrix[1][1]->resp.mpr_rec.hops); - cl_qlist_insert_tail(p_list, &matrix[0][0]->list_item); - cl_qlist_insert_tail(p_list, &matrix[1][1]->list_item); + matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.slid : 0, + matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.dlid : 0, + matrix[0][0] ? matrix[0][0]->resp.mpr_rec.hops : 0, + matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.slid : 0, + matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.dlid : 0, + matrix[1][1] ? matrix[1][1]->resp.mpr_rec.hops : 0); + if (matrix[0][0]) + cl_qlist_insert_tail(p_list, &matrix[0][0]->list_item); + if (matrix[1][1]) + cl_qlist_insert_tail(p_list, &matrix[1][1]->list_item); free(matrix[0][1]); free(matrix[1][0]); } else { @@ -1457,14 +1479,16 @@ static void mpr_rcv_get_apm_paths(IN osm_sa_t * sa, OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Diag {0,1} & {1,0} is the best:\n" "\t{0,1} 0x%X->0x%X (%d)\t & {1,0} 0x%X->0x%X (%d)\n", - matrix[0][1]->resp.mpr_rec.path_rec.slid, - matrix[0][1]->resp.mpr_rec.path_rec.dlid, - matrix[0][1]->resp.mpr_rec.hops, - matrix[1][0]->resp.mpr_rec.path_rec.slid, - matrix[1][0]->resp.mpr_rec.path_rec.dlid, - matrix[1][0]->resp.mpr_rec.hops); - cl_qlist_insert_tail(p_list, &matrix[0][1]->list_item); - cl_qlist_insert_tail(p_list, &matrix[1][0]->list_item); + matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.slid : 0, + matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.dlid : 0, + matrix[0][1] ? matrix[0][1]->resp.mpr_rec.hops : 0, + matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.slid : 0, + matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.dlid: 0, + matrix[1][0] ? matrix[1][0]->resp.mpr_rec.hops : 0); + if (matrix[0][1]) + cl_qlist_insert_tail(p_list, &matrix[0][1]->list_item); + if (matrix[1][0]) + cl_qlist_insert_tail(p_list, &matrix[1][0]->list_item); free(matrix[0][0]); free(matrix[1][1]); }