[ofa-general] Re: [PATCH] opensm: wrong variable memset()

Sasha Khapyorsky sashak at voltaire.com
Sun Aug 5 12:35:03 PDT 2007


On 14:40 Sun 05 Aug     , Hal Rosenstock wrote:
> On 8/5/07, Sasha Khapyorsky <sashak at voltaire.com> wrote:
> > On 12:25 Sun 05 Aug     , Hal Rosenstock wrote:
> > > >
> > > > diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
> > > > index 1cf6257..2e43f86 100644
> > > > --- a/opensm/opensm/osm_state_mgr.c
> > > > +++ b/opensm/opensm/osm_state_mgr.c
> > > > @@ -587,7 +587,7 @@ __osm_state_mgr_get_sw_info(
> > > >    p_node = p_sw->p_node;
> > > >    p_dr_path = osm_node_get_any_dr_path_ptr( p_node );
> > > >
> > > > -   memset( &context, 0, sizeof( context ) );
> > > > +   memset( &mad_context, 0, sizeof( mad_context ) );
> > >
> > > Nice catch. Should this also be applied for 1.2.c/1.2.1 ?
> >
> > I don't think - it killed the content of variable which was not used
> > later, so this bug is pretty minor.
> 
> It looked to me like it cleared p_mgr which is used later.

No, local var 'p_mgr' is initialized already as value (not address) of
'context', then _value_ of 'context' is cleared by this wrong memset(),
but as function argument it is on the stack and not used anymore.

Sasha



More information about the general mailing list