[igt-dev] [PATCH i-g-t 1/3] lib/igt_chamelium: Sanitize the init error and deinit path

Kunal Joshi kunal1.joshi at intel.com
Tue Jul 7 08:19:49 UTC 2020


Hi,

On 2020-07-07 at 16:18:12 +0300, Imre Deak wrote:
> Always return NULL from init in case of an error, and reuse
> chamelium_deinit_rpc_only() for symmetry with init, instead of
> open-coding the same.
> 
> Cc: Lyude Paul <lyude at redhat.com>
> Cc: Kunal Joshi <kunal1.joshi at intel.com>
> Signed-off-by: Imre Deak <imre.deak at intel.com>
Reviewed-by: Kunal Joshi <kunal1.joshi at intel.com>
For the whole series
> ---
>  lib/igt_chamelium.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 58e01ab72..5924e5615 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -2512,7 +2512,8 @@ struct chamelium *chamelium_init(int drm_fd)
>  	return chamelium;
>  error:
>  	chamelium_deinit_rpc_only(chamelium);
> -	return chamelium;
> +
> +	return NULL;
>  }
>  
>  /**
> @@ -2550,12 +2551,11 @@ void chamelium_deinit(struct chamelium *chamelium)
>  	}
>  
>  	xmlrpc_client_destroy(chamelium->client);
> -	xmlrpc_env_clean(&chamelium->env);
>  
>  	for (i = 0; i < chamelium->port_count; i++)
>  		free(chamelium->ports[i].name);
>  
> -	free(chamelium);
> +	chamelium_deinit_rpc_only(chamelium);
>  }
>  
>  bool chamelium_plug_all(struct chamelium *chamelium)
> -- 
> 2.23.1
> 


More information about the igt-dev mailing list