[ofa-general] Re: [PATCH] opensm/osm_sa_slvl_record: fix overflow crash

Sasha Khapyorsky sashak at voltaire.com
Sun Jan 13 00:21:04 PST 2008


Hi Hal,

On 07:24 Thu 10 Jan     , Hal Rosenstock wrote:
> On Wed, 2008-01-09 at 19:41 +0000, Sasha Khapyorsky wrote:
> > When SL2VLTableRecord is requested for switch by lid only (no in and out
> > ports are selected in compmask) it overflows its own physical ports
> > table.
> > 
> > Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
> > ---
> >  opensm/opensm/osm_sa_slvl_record.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/opensm/opensm/osm_sa_slvl_record.c b/opensm/opensm/osm_sa_slvl_record.c
> > index 28dddd4..cc21765 100644
> > --- a/opensm/opensm/osm_sa_slvl_record.c
> > +++ b/opensm/opensm/osm_sa_slvl_record.c
> > @@ -149,9 +149,9 @@ __osm_sa_slvl_by_comp_mask(IN osm_sa_t * sa,
> >  	comp_mask = p_ctxt->comp_mask;
> >  	num_ports = osm_node_get_num_physp(p_port->p_node);
> >  	in_port_start = 0;
> > -	in_port_end = num_ports;
> > +	in_port_end = num_ports - 1;
> >  	out_port_start = 0;
> > -	out_port_end = num_ports;
> > +	out_port_end = num_ports - 1;
> >  	p_req_physp = p_ctxt->p_req_physp;
> >  
> >  	if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
> 
> Minor comment:
> Rather than subtracting 1 from in/out_port_end, wouldn't changing the
> input and output port number comparisons to < rather than <= work (and
> be more consistent with other SA record handling) ?

In this particular SA processor the only using '<' instead of '<=' will
break the case when in- or out- ports are requested in a comp mask.

Sasha



More information about the general mailing list