[ofa-general] [PATCH] opensm/opensm/osm_console.c: fix seg fault when running "portstatus ca" in the console

Ira Weiny weiny2 at llnl.gov
Fri Feb 8 13:44:13 PST 2008


The osm_node_get_physp_ptr now returns NULL for invalid ports.  Check for this before using the pointer.

Ira


>From 33dba7f427c38a4bc71bebaca82567c8857e901a Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Fri, 8 Feb 2008 13:39:29 -0800
Subject: [PATCH] opensm/opensm/osm_console.c: fix seg fault when running "portstatus ca" in the

console

Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 opensm/opensm/osm_console.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index 8b6642e..44209af 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -555,17 +555,25 @@ static void __get_stats(cl_map_item_t * const p_map_item, void *context)
 
 	for (port = 1; port < num_ports; port++) {
 		osm_physp_t *phys = osm_node_get_physp_ptr(node, port);
-		ib_port_info_t *pi = &(phys->port_info);
-		uint8_t active_speed = ib_port_info_get_link_speed_active(pi);
-		uint8_t enabled_speed = ib_port_info_get_link_speed_enabled(pi);
-		uint8_t active_width = pi->link_width_active;
-		uint8_t enabled_width = pi->link_width_enabled;
-		uint8_t port_state = ib_port_info_get_port_state(pi);
-		uint8_t port_phys_state = ib_port_info_get_port_phys_state(pi);
+		ib_port_info_t *pi = NULL;
+		uint8_t active_speed = 0;
+		uint8_t enabled_speed = 0;
+		uint8_t active_width = 0;
+		uint8_t enabled_width = 0;
+		uint8_t port_state = 0;
+		uint8_t port_phys_state = 0;
 
 		if (!phys)
 			continue;
 
+		pi = &(phys->port_info);
+		active_speed = ib_port_info_get_link_speed_active(pi);
+		enabled_speed = ib_port_info_get_link_speed_enabled(pi);
+		active_width = pi->link_width_active;
+		enabled_width = pi->link_width_enabled;
+		port_state = ib_port_info_get_port_state(pi);
+		port_phys_state = ib_port_info_get_port_phys_state(pi);
+
 		if ((enabled_width ^ active_width) > active_width) {
 			__tag_port_report(&(fs->reduced_width_ports),
 					  cl_ntoh64(node->node_info.node_guid),
-- 
1.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-opensm-opensm-osm_console.c-fix-seg-fault-when-runn.patch
Type: application/octet-stream
Size: 1926 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080208/2ea20abf/attachment.obj>


More information about the general mailing list