[ofa-general] Re: [PATCH 1/3] OpenSM: Add null dereference checks

Sasha Khapyorsky sashak at voltaire.com
Sun Dec 9 11:27:47 PST 2007


Hi Al,

On 16:54 Fri 07 Dec     , Al Chu wrote:
> Hey Sasha,
> 
> Nothing fancy.  Just noticed the check is done in the ftree equivalent
> destroy function so I figured it should be in the others.

Is it possible/legal usage to have context = NULL in those desctructors?
If not, I don't think we need such checks.

Sasha

> 
> Al
> 
> -- 
> Albert Chu
> chu11 at llnl.gov
> 925-422-5311
> Computer Scientist
> High Performance Systems Division
> Lawrence Livermore National Laboratory

> From c94361165ab2a3c6e8dadb6596d97d79e36bb1f6 Mon Sep 17 00:00:00 2001
> From: Albert L. Chu <chu11 at llnl.gov>
> Date: Fri, 7 Dec 2007 13:43:15 -0800
> Subject: [PATCH] add null check in context destroy functions
> 
> 
> Signed-off-by: Albert L. Chu <chu11 at llnl.gov>
> ---
>  opensm/opensm/osm_ucast_lash.c |    2 ++
>  opensm/opensm/osm_ucast_updn.c |    3 +++
>  2 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
> index 5e7716e..bdcd2d1 100644
> --- a/opensm/opensm/osm_ucast_lash.c
> +++ b/opensm/opensm/osm_ucast_lash.c
> @@ -1469,6 +1469,8 @@ static lash_t *lash_create(osm_opensm_t * p_osm)
>  static void lash_delete(void *context)
>  {
>  	lash_t *p_lash = context;
> +        if (!context)
> +                return;
>  	if (p_lash->switches) {
>  		unsigned id;
>  		for (id = 0; ((int)id) < p_lash->num_switches; id++)
> diff --git a/opensm/opensm/osm_ucast_updn.c b/opensm/opensm/osm_ucast_updn.c
> index 0b7b1a9..24c9fe3 100644
> --- a/opensm/opensm/osm_ucast_updn.c
> +++ b/opensm/opensm/osm_ucast_updn.c
> @@ -234,6 +234,9 @@ static void updn_destroy(IN updn_t * const p_updn)
>  {
>  	uint64_t *p_guid_list_item;
>  
> +        if (!p_updn)
> +                return;
> +
>  	/* free the array of guids */
>  	if (p_updn->updn_ucast_reg_inputs.guid_list)
>  		free(p_updn->updn_ucast_reg_inputs.guid_list);
> -- 
> 1.5.1
> 




More information about the general mailing list