[ofa-general] Re: [PATCH] opensm/osm_switch.c: In osm_switch_delete, set priv to NULL

Hal Rosenstock hal.rosenstock at gmail.com
Mon Jul 27 09:41:42 PDT 2009


Hi Sasha,

On Mon, Jul 27, 2009 at 12:32 PM, Sasha Khapyorsky<sashak at voltaire.com> wrote:
> Hi Hal,
>
> On 19:04 Fri 24 Jul     , Hal Rosenstock wrote:
>>
>> This can help with finding use after free issues if memory not reused
>> updn and lash rely on this priv pointer and may have stale
>> osm_switch_t pointers
>
> As far as I remember LASH and UPDN should never be in this state. If you
> are able to see such cases this indicates some serious bug (probably
> race between SA PR processor and drop manager if it happens with LASH)
> and actually is a good environment for finding and fixing.
>
> The proposed patch is just hide a *real* problem (unless I'm wrong
> above and the case is legal).

The intent of the patch is to cause a NULL ptr fault rather than using
memory not currently owned. The latter can have unpredictable results.

-- Hal

> Sasha
>
>>
>> Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
>> ---
>> diff --git a/opensm/opensm/osm_switch.c b/opensm/opensm/osm_switch.c
>> index ce1ca63..e23b32f 100644
>> --- a/opensm/opensm/osm_switch.c
>> +++ b/opensm/opensm/osm_switch.c
>> @@ -94,6 +94,7 @@ void osm_switch_delete(IN OUT osm_switch_t ** const pp_sw)
>>                               free(p_sw->hops[i]);
>>               free(p_sw->hops);
>>       }
>> +     p_sw->priv = NULL;
>>       free(*pp_sw);
>>       *pp_sw = NULL;
>>  }
>>
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
>
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
>



More information about the general mailing list