Hey Sasha,

I noticed that in osm_ucast_updn_setup(), the code has set the
context/callbacks in the routing engine struct, but does not revert the
changes if the later call to updn_init() fails.  The callbacks would be
left in place and erroneously executed at a later time.  Patch is
attached.

Thanks,
Al

-- 
Albert Chu
[EMAIL PROTECTED]
925-422-5311
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
>From caeb46ed713df285785d84930b1db1850e11d19b Mon Sep 17 00:00:00 2001
From: Albert L. Chu <[EMAIL PROTECTED]>
Date: Mon, 10 Dec 2007 16:27:07 -0800
Subject: [PATCH] fix error return corner case


Signed-off-by: Albert L. Chu <[EMAIL PROTECTED]>
---
 opensm/opensm/osm_ucast_updn.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/opensm/opensm/osm_ucast_updn.c b/opensm/opensm/osm_ucast_updn.c
index 0b7b1a9..2c5eb65 100644
--- a/opensm/opensm/osm_ucast_updn.c
+++ b/opensm/opensm/osm_ucast_updn.c
@@ -239,12 +239,13 @@ static void updn_destroy(IN updn_t * const p_updn)
 		free(p_updn->updn_ucast_reg_inputs.guid_list);
 
 	/* destroy the list of root nodes */
-	while ((p_guid_list_item = cl_list_remove_head(p_updn->p_root_nodes)))
-		free(p_guid_list_item);
-
-	cl_list_remove_all(p_updn->p_root_nodes);
-	cl_list_destroy(p_updn->p_root_nodes);
-	free(p_updn->p_root_nodes);
+        if (p_updn->p_root_nodes) {
+                while ((p_guid_list_item = cl_list_remove_head(p_updn->p_root_nodes)))
+                        free(p_guid_list_item);
+                cl_list_remove_all(p_updn->p_root_nodes);
+                cl_list_destroy(p_updn->p_root_nodes);
+                free(p_updn->p_root_nodes);
+        }
 	free(p_updn);
 }
 
@@ -815,13 +816,15 @@ int osm_ucast_updn_setup(osm_opensm_t * p_osm)
 	if (!p_updn)
 		return -1;
 
+	if (updn_init(p_updn, p_osm) != IB_SUCCESS) {
+                updn_destroy(p_updn);
+		return -1;
+        }
+
 	p_osm->routing_engine.context = p_updn;
 	p_osm->routing_engine.delete = __osm_updn_delete;
 	p_osm->routing_engine.build_lid_matrices = __osm_updn_call;
 
-	if (updn_init(p_updn, p_osm) != IB_SUCCESS)
-		return -1;
-
 	if (!p_updn->auto_detect_root_nodes)
 		__osm_updn_convert_list2array(p_updn);
 
-- 
1.5.1

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to