diff mbox

[infiniband-diags,2/2] fix potential segfault in ibnd_node_t destroy path

Message ID 1257531264.18550.70.camel@auk31.llnl.gov (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Al Chu Nov. 6, 2009, 6:14 p.m. UTC
None
diff mbox

Patch

diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc.c b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
index 62dff93..7ce9a54 100644
--- a/infiniband-diags/libibnetdisc/src/ibnetdisc.c
+++ b/infiniband-diags/libibnetdisc/src/ibnetdisc.c
@@ -605,10 +605,12 @@  static void destroy_node(ibnd_node_t * node)
 {
 	int p = 0;
 
-	for (p = 0; p <= node->numports; p++) {
-		free(node->ports[p]);
+	if (node->ports) {
+		for (p = 0; p <= node->numports; p++) {
+			free(node->ports[p]);
+		}
+		free(node->ports);
 	}
-	free(node->ports);
 	free(node);
 }