[ofa-general] [PATCH] Fix 2 potential core dumps now that osm_node_get_physp_ptr can return NULL

Ira Weiny weiny2 at llnl.gov
Wed Feb 20 14:02:45 PST 2008


Sasha,

I actually hit these when I was testing with a low OSM_UMAD_MAX_PENDING value.
I was a bit unsure of what to do in these cases if p_physp was NULL.  What I do
in this patch seems reasonable as the fabric does route but perhaps you could
double check me?

Thanks,
Ira


>From 310a6cceca946fcc86f7bec28dfdeba77d011fc5 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Wed, 20 Feb 2008 13:53:51 -0800
Subject: [PATCH] Fix 2 potential core dumps now that osm_node_get_physp_ptr can return NULL


Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 opensm/opensm/osm_node.c       |    2 ++
 opensm/opensm/osm_ucast_updn.c |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_node.c b/opensm/opensm/osm_node.c
index 85ea3c9..843f7c8 100644
--- a/opensm/opensm/osm_node.c
+++ b/opensm/opensm/osm_node.c
@@ -285,6 +285,8 @@ osm_node_t *osm_node_get_remote_node(IN osm_node_t * const p_node,
 	osm_physp_t *p_remote_physp;
 
 	p_physp = osm_node_get_physp_ptr(p_node, port_num);
+	if (!p_physp)
+		return (NULL);
 
 	if (!osm_physp_has_any_link(p_physp))
 		return (NULL);
diff --git a/opensm/opensm/osm_ucast_updn.c b/opensm/opensm/osm_ucast_updn.c
index 76b94cb..a7d61aa 100644
--- a/opensm/opensm/osm_ucast_updn.c
+++ b/opensm/opensm/osm_ucast_updn.c
@@ -377,6 +377,10 @@ updn_subn_rank(IN unsigned num_guids,
 			/* Current port fetched in order to get remote side */
 			p_physp =
 			    osm_node_get_physp_ptr(p_sw->p_node, port_num);
+
+			if (!p_physp)
+				continue;
+
 			p_remote_physp = p_physp->p_remote_physp;
 
 			/*
-- 
1.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fix-2-potential-core-dumps-now-that-osm_node_get_phy.patch
Type: application/octet-stream
Size: 1324 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20080220/2eb4b8b5/attachment.obj>


More information about the general mailing list