Commit d0e473d7 authored by Imre Deak's avatar Imre Deak

lib/igt_chamelium: Sanitize the init error and deinit path

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@redhat.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Imre Deak's avatarImre Deak <imre.deak@intel.com>
Reviewed-by: KunalJoshi95's avatarKunal Joshi <kunal1.joshi@intel.com>
parent 90254c14
...@@ -2512,7 +2512,8 @@ struct chamelium *chamelium_init(int drm_fd) ...@@ -2512,7 +2512,8 @@ struct chamelium *chamelium_init(int drm_fd)
return chamelium; return chamelium;
error: error:
chamelium_deinit_rpc_only(chamelium); chamelium_deinit_rpc_only(chamelium);
return chamelium;
return NULL;
} }
/** /**
...@@ -2550,12 +2551,11 @@ void chamelium_deinit(struct chamelium *chamelium) ...@@ -2550,12 +2551,11 @@ void chamelium_deinit(struct chamelium *chamelium)
} }
xmlrpc_client_destroy(chamelium->client); xmlrpc_client_destroy(chamelium->client);
xmlrpc_env_clean(&chamelium->env);
for (i = 0; i < chamelium->port_count; i++) for (i = 0; i < chamelium->port_count; i++)
free(chamelium->ports[i].name); free(chamelium->ports[i].name);
free(chamelium); chamelium_deinit_rpc_only(chamelium);
} }
bool chamelium_plug_all(struct chamelium *chamelium) bool chamelium_plug_all(struct chamelium *chamelium)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment