[ofa-general] [PATCH] opensm/console: dump_portguid command fixes

Sasha Khapyorsky sashak at voltaire.com
Tue Feb 17 10:50:27 PST 2009


Don't try to match invalid expressions, so things like 'dump_portguid *'
will not crash.

Free memory allocated by regcomp() and for regexp list.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/opensm/osm_console.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index a66a7d3..0f26e51 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -1247,6 +1247,8 @@ static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 					fprintf(out,
 						"Couldn't parse regular expression %s. Skipping it.\n",
 						p_cmd);
+					free(p_regexp);
+					continue;
 				}
 				p_regexp->next = p_head_regexp;
 				p_head_regexp = p_regexp;
@@ -1292,6 +1294,11 @@ static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 	if (output != out)
 		fclose(output);
 
+	for (; p_head_regexp; p_head_regexp = p_regexp) {
+		p_regexp = p_head_regexp->next;
+		regfree(&p_head_regexp->exp);
+		free(p_head_regexp);
+	}
 }
 
 static void help_dump_portguid(FILE * out, int detail)
-- 
1.6.1.2.319.gbd9e




More information about the general mailing list