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 AA8D5A00E6 for ; Mon, 5 Aug 2019 10:48:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2985C1BE1F; Mon, 5 Aug 2019 10:48:24 +0200 (CEST) Received: from alln-iport-4.cisco.com (alln-iport-4.cisco.com [173.37.142.91]) by dpdk.org (Postfix) with ESMTP id 9EF7F1BE0F for ; Mon, 5 Aug 2019 10:48:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1664; q=dns/txt; s=iport; t=1564994902; x=1566204502; h=from:to:cc:subject:date:message-id:mime-version; bh=65uWv5DNvKEU207/Yat/TlguPmwKm+nokIms6TT6i0k=; b=JDH4yPn016Yg3dNVOYgY66QSfR1BHLv8L/OcOrnrg5v4gAijtdHnmmk0 TBPYZnNs4+BS0cjZtJ21MpoymSnutY53icJV+iiW73s0EMFAgKT/wZ2TF JwpcoGpbM7DWiiy9xpi3z1W6IEuJSixD3GIP32Z2g53nmfAUyWkPDh3sP I=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AYAAAb7Edd/5JdJa1mGgEBAQEBAgE?= =?us-ascii?q?BAQEHAgEBAQGBVAQBAQEBCwGCF4E/ATEqCp9LjyKBewkBAQEMAQEvAQGEP4J?= =?us-ascii?q?nIzUIDgEDAQEEAQECAQZthSqFeFKBPg4FgyKBdxSsEzOFSYMugUiBNAGHCYR?= =?us-ascii?q?ZF4FAP4ERgXCBYIURhRYEjCWKEpRpCYIdlBIMG5goAaU3AhEVgVIBNYFYTSM?= =?us-ascii?q?VgyeCTQEXjiM9AQExjRsBgSABAQ?= X-IronPort-AV: E=Sophos;i="5.64,349,1559520000"; d="scan'208";a="301259825" Received: from rcdn-core-10.cisco.com ([173.37.93.146]) by alln-iport-4.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 05 Aug 2019 08:48:21 +0000 Received: from XCH-ALN-004.cisco.com (xch-aln-004.cisco.com [173.36.7.14]) by rcdn-core-10.cisco.com (8.15.2/8.15.2) with ESMTPS id x758mL9v022652 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL) for ; Mon, 5 Aug 2019 08:48:21 GMT Received: from ja-VirtualBox.pantheon.local (10.61.250.185) by XCH-ALN-004.cisco.com (173.36.7.14) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 5 Aug 2019 03:48:19 -0500 From: Jakub Grajciar To: CC: Jakub Grajciar Date: Mon, 5 Aug 2019 10:48:06 +0200 Message-ID: <20190805084806.4320-1-jgrajcia@cisco.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.61.250.185] X-ClientProxiedBy: xch-rtp-010.cisco.com (64.101.220.150) To XCH-ALN-004.cisco.com (173.36.7.14) X-Outbound-SMTP-Client: 173.36.7.14, xch-aln-004.cisco.com X-Outbound-Node: rcdn-core-10.cisco.com Subject: [dpdk-dev] [PATCH] net/memif: fix coverity defects 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" fixes CID: 343440, 343459, 343464, 343394 Signed-off-by: Jakub Grajciar --- drivers/net/memif/memif_socket.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c index 01a935f87..65dff321c 100644 --- a/drivers/net/memif/memif_socket.c +++ b/drivers/net/memif/memif_socket.c @@ -852,7 +852,7 @@ memif_listener_handler(void *arg) return; error: - if (sockfd > 0) { + if (sockfd >= 0) { close(sockfd); sockfd = -1; } @@ -921,6 +921,8 @@ memif_socket_create(struct pmd_internals *pmd, char *key, uint8_t listener) rte_vdev_device_name(pmd->vdev), key, strerror(errno)); if (sock != NULL) rte_free(sock); + if (sockfd >= 0) + close (sockfd); return NULL; } @@ -1010,6 +1012,7 @@ memif_socket_remove_device(struct rte_eth_dev *dev) struct memif_socket *socket = NULL; struct memif_socket_dev_list_elt *elt, *next; struct rte_hash *hash; + int ret; hash = rte_hash_find_existing(MEMIF_SOCKET_HASH_NAME); if (hash == NULL) @@ -1037,7 +1040,10 @@ memif_socket_remove_device(struct rte_eth_dev *dev) /* remove listener socket file, * so we can create new one later. */ - remove(socket->filename); + ret = remove(socket->filename); + if (ret < 0) + MIF_LOG(ERR, "Failed to remove socket file: %s", + socket->filename); } rte_free(socket); } @@ -1113,7 +1119,7 @@ memif_connect_slave(struct rte_eth_dev *dev) return 0; error: - if (sockfd > 0) { + if (sockfd >= 0) { close(sockfd); sockfd = -1; } -- 2.17.1