From 2722f20cbda88b5f6250213a7be8412c19a11e8a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 14 May 2021 15:24:27 -0400 Subject: [PATCH] Fix: shutdown communication socket on -EINVAL Found by Coverity: >>> CID 1453150: Control flow issues (DEADCODE) >>> Execution cannot reach this statement: "(void)ustcomm_shutdown_unix...". Signed-off-by: Mathieu Desnoyers Change-Id: I151e86167e8467ce3b602ddd0258284e0ef53eaa --- src/lib/lttng-ust-ctl/ustctl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/lttng-ust-ctl/ustctl.c b/src/lib/lttng-ust-ctl/ustctl.c index 46a1c89d..784cb75d 100644 --- a/src/lib/lttng-ust-ctl/ustctl.c +++ b/src/lib/lttng-ust-ctl/ustctl.c @@ -394,15 +394,15 @@ int lttng_ust_ctl_add_context(int sock, struct lttng_ust_context_attr *ctx, } ret = ustcomm_recv_app_reply(sock, &lur, lum.handle, lum.cmd); if (ret < 0) { + if (ret == -EINVAL) { + /* + * Command unknown from remote end. The communication socket is + * now out-of-sync and needs to be shutdown. + */ + (void) ustcomm_shutdown_unix_sock(sock); + } goto end; - } else if (ret == -EINVAL) { - /* - * Command unknown from remote end. The communication socket is - * now out-of-sync and needs to be shutdown. - */ - (void) ustcomm_shutdown_unix_sock(sock); } - context_data->handle = -1; DBG("Context created successfully"); *_context_data = context_data; -- 2.34.1