22672457 ibqueryerrors dumps core with invalid port specified s11u3-sru
authorboris.chiu@oracle.com
Mon, 03 Oct 2016 15:42:44 -0700
branchs11u3-sru
changeset 7023 4afb0efdefc1
parent 7022 a132ff51166e
child 7024 84310b997802
22672457 ibqueryerrors dumps core with invalid port specified
components/open-fabrics/infiniband-diags/patches/004-infiniband-diags-coredump_due_to_invalid_port.patch
components/open-fabrics/libibmad/patches/003-libibmad-coredump_due_to_invalid_port.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/open-fabrics/infiniband-diags/patches/004-infiniband-diags-coredump_due_to_invalid_port.patch	Mon Oct 03 15:42:44 2016 -0700
@@ -0,0 +1,43 @@
+# This patch was developed both in-house and from outside. We plan to submit it
+# upstream, but do not yet have a target date for doing so
+#
+# HG changeset patch
+# Parent  15a2d43c5282731628f52799d6cee479851014df
+22672457 ibqueryerrors dumps core with invalid port specified
+
+diff -r 15a2d43c5282 libibnetdisc/src/ibnetdisc.c
+--- a/libibnetdisc/src/ibnetdisc.c	Tue Sep 13 10:09:52 2016 -0700
++++ b/libibnetdisc/src/ibnetdisc.c	Tue Sep 13 10:29:00 2016 -0700
+@@ -610,7 +610,11 @@
+ ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str)
+ {
+ 	ibnd_port_t *rc = ibnd_find_port_dr(fabric, dr_str);
+-	return rc->node;
++	/* Check whether the specified port is found */
++	if (rc == NULL)
++		return NULL;
++	else
++		return rc->node;
+ }
+ 
+ void add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[])
+@@ -911,6 +915,8 @@
+ 	}
+ 
+ 	cur_node = fabric->from_node;
++	if (!cur_node)
++		return NULL;
+ 
+ 	if (str2drpath(&path, dr_str, 0, 0) == -1)
+ 		return NULL;
+@@ -921,6 +927,10 @@
+ 			continue;
+ 		if (!cur_node->ports)
+ 			return NULL;
++		/* check the existence of the port specified in dr path */
++		if (path.p[i] > cur_node->numports ||
++		    cur_node->ports[path.p[i]] == NULL)
++			return NULL;
+ 
+ 		remote_port = cur_node->ports[path.p[i]]->remoteport;
+ 		if (!remote_port)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/open-fabrics/libibmad/patches/003-libibmad-coredump_due_to_invalid_port.patch	Mon Oct 03 15:42:44 2016 -0700
@@ -0,0 +1,46 @@
+# This patch was developed both in-house and from outside. We plan to submit it
+# upstream, but do not yet have a target date for doing so
+#
+# HG changeset patch
+# Parent  1e024aba6f841541c36f2c618a0b9436124be5ba
+22672457 ibqueryerrors dumps core with invalid port specified
+
+diff -r 1e024aba6f84 src/portid.c
+--- a/src/portid.c	Mon Aug 29 10:50:40 2016 -0700
++++ b/src/portid.c	Thu Sep 01 15:55:44 2016 -0700
+@@ -82,7 +82,25 @@
+ 
+ int str2drpath(ib_dr_path_t * path, char *routepath, int drslid, int drdlid)
+ {
+-	char *s, *str = routepath;
++	char *s, *str;
++	char *buf;
++	int str_len;
++
++	if (routepath == NULL)
++		return -1;
++
++	/* Copy the content of routepath into buf for processing */
++	str_len = strlen(routepath);
++	if (str_len == 0)
++		return -1;
++	
++	buf = (char *) malloc((str_len + 1) * sizeof(char));
++	if (!buf) {
++		return -1;
++	}
++	strncpy(buf, routepath, str_len);
++	buf[str_len] = '\0';
++	str = buf;
+ 
+ 	path->cnt = -1;
+ 
+@@ -99,6 +117,8 @@
+ 	path->drdlid = drdlid ? drdlid : 0xffff;
+ 	path->drslid = drslid ? drslid : 0xffff;
+ 
++	free(buf);
++
+ 	return path->cnt;
+ }
+