[ofa-general] [PATCH] opensm/osm_ucast_lash.c: Eliminate possible seg fault in get_osm_switch_from_port

Hal Rosenstock hnrose at comcast.net
Sat Jul 11 04:48:15 PDT 2009


get_osm_switch_from_port can be called with NULL port pointer
from osm_get_lash_sl

Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index 12b5e34..871a673 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -5,6 +5,7 @@
  * Copyright (c) 2007      Simula Research Laboratory. All rights reserved.
  * Copyright (c) 2007      Silicon Graphics Inc. All rights reserved.
  * Copyright (c) 2008,2009 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2009      HNR Consulting. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -129,7 +130,11 @@ static void connect_switches(lash_t * p_lash, int sw1, int sw2, int phy_port_1)
 
 static osm_switch_t *get_osm_switch_from_port(const osm_port_t * port)
 {
-	osm_physp_t *p = port->p_physp;
+	osm_physp_t *p;
+
+	if (!port)
+		return NULL;
+	p = port->p_physp;
 	if (p->p_node->sw)
 		return p->p_node->sw;
 	else if (p->p_remote_physp->p_node->sw)



More information about the general mailing list