components/open-fabrics/infiniband-diags/patches/004-infiniband-diags-coredump_due_to_invalid_port.patch
branchs11u3-sru
changeset 7023 4afb0efdefc1
equal deleted inserted replaced
7022:a132ff51166e 7023:4afb0efdefc1
       
     1 # This patch was developed both in-house and from outside. We plan to submit it
       
     2 # upstream, but do not yet have a target date for doing so
       
     3 #
       
     4 # HG changeset patch
       
     5 # Parent  15a2d43c5282731628f52799d6cee479851014df
       
     6 22672457 ibqueryerrors dumps core with invalid port specified
       
     7 
       
     8 diff -r 15a2d43c5282 libibnetdisc/src/ibnetdisc.c
       
     9 --- a/libibnetdisc/src/ibnetdisc.c	Tue Sep 13 10:09:52 2016 -0700
       
    10 +++ b/libibnetdisc/src/ibnetdisc.c	Tue Sep 13 10:29:00 2016 -0700
       
    11 @@ -610,7 +610,11 @@
       
    12  ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str)
       
    13  {
       
    14  	ibnd_port_t *rc = ibnd_find_port_dr(fabric, dr_str);
       
    15 -	return rc->node;
       
    16 +	/* Check whether the specified port is found */
       
    17 +	if (rc == NULL)
       
    18 +		return NULL;
       
    19 +	else
       
    20 +		return rc->node;
       
    21  }
       
    22  
       
    23  void add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[])
       
    24 @@ -911,6 +915,8 @@
       
    25  	}
       
    26  
       
    27  	cur_node = fabric->from_node;
       
    28 +	if (!cur_node)
       
    29 +		return NULL;
       
    30  
       
    31  	if (str2drpath(&path, dr_str, 0, 0) == -1)
       
    32  		return NULL;
       
    33 @@ -921,6 +927,10 @@
       
    34  			continue;
       
    35  		if (!cur_node->ports)
       
    36  			return NULL;
       
    37 +		/* check the existence of the port specified in dr path */
       
    38 +		if (path.p[i] > cur_node->numports ||
       
    39 +		    cur_node->ports[path.p[i]] == NULL)
       
    40 +			return NULL;
       
    41  
       
    42  		remote_port = cur_node->ports[path.p[i]]->remoteport;
       
    43  		if (!remote_port)