From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A9FAC433E7 for ; Tue, 13 Oct 2020 15:57:16 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id E2E1325220 for ; Tue, 13 Oct 2020 15:57:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2E1325220 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 33F161DA90; Tue, 13 Oct 2020 17:57:13 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id B05291D92B for ; Tue, 13 Oct 2020 17:57:10 +0200 (CEST) IronPort-SDR: tZD48GkWghJ2G9o4aSfjrnQpVksM1NvAXwgMldKluuD2ZP3Z9za2V/aeSxltbQFUd4U+ObXzQt deTb39xxv94w== X-IronPort-AV: E=McAfee;i="6000,8403,9773"; a="165144415" X-IronPort-AV: E=Sophos;i="5.77,371,1596524400"; d="scan'208";a="165144415" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 08:56:55 -0700 IronPort-SDR: tO+uNCptWLIShwdW+CgZAg0yurgydXoknzwR11opyZdSkJ1O3g/5Z6uWvMP7x4/ETCpw2uXgPs r3X+jBOuak6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,371,1596524400"; d="scan'208";a="345311203" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.222.239]) by fmsmga004.fm.intel.com with ESMTP; 13 Oct 2020 08:56:54 -0700 From: Ciara Power To: dev@dpdk.org Cc: Ciara Power , Kevin Laatz Date: Tue, 13 Oct 2020 16:56:48 +0100 Message-Id: <20201013155648.3471-1-ciara.power@intel.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] test/telemetry: fix socket resource leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If an error occurred when reading from the socket, the function returned without closing the socket. This is now fixed to avoid the resource leak of the sock variable going out of scope. Fixes: bd78cf693ebd ("test/telemetry: add unit tests for data to JSON") Coverity issue: 363043 Signed-off-by: Ciara Power --- app/test/test_telemetry_data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index 7a31e68a78..f3807a7255 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -327,6 +327,7 @@ connect_to_socket(void) if (bytes < 0) { printf("%s: Error with socket read - %s\n", __func__, strerror(errno)); + close(sock); return -1; } buf[bytes] = '\0'; -- 2.22.0