From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7D0346E0BA for ; Tue, 7 Jul 2020 13:18:18 +0000 (UTC) From: Imre Deak Date: Tue, 7 Jul 2020 16:18:12 +0300 Message-Id: <20200707131814.17540-1-imre.deak@intel.com> MIME-Version: 1.0 Subject: [igt-dev] [PATCH i-g-t 1/3] lib/igt_chamelium: Sanitize the init error and deinit path List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: igt-dev@lists.freedesktop.org Cc: Kunal Joshi List-ID: 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 Cc: Kunal Joshi Signed-off-by: Imre Deak --- 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 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev