From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 236E4A04B7; Tue, 13 Oct 2020 17:57:15 +0200 (CEST) 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