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 88F2DA00E6 for ; Mon, 5 Aug 2019 11:08:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8C3B41BD4F; Mon, 5 Aug 2019 11:08:04 +0200 (CEST) Received: from alln-iport-3.cisco.com (alln-iport-3.cisco.com [173.37.142.90]) by dpdk.org (Postfix) with ESMTP id 00F531B9D6 for ; Mon, 5 Aug 2019 11:08:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1685; q=dns/txt; s=iport; t=1564996083; x=1566205683; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JfVf7DODeU7r/h+je/ddHCABnW50RR9/sUUW/qt6NLE=; b=dAnKinxNKkVoDqZozHzqrpVMu9Gb5KF38xE67qdtVlWP9CVFygWYjIPS /aIqRO3aGy73xtCamKJqd+Y3fwR82QtWpPnjnVz0Fl6zhNuYIvf6M4FlD vcGbMnAkOpTFOlp+rxqWygs7ELmiuP76ntpWNyXn8AnWgmkh0yskfAiv9 w=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AZAAAq8Udd/5JdJa1mGQEBAQEBAQE?= =?us-ascii?q?BAQEBAQcBAQEBAQGBVQIBAQEBAQsBgheBPwExKgqfSo8igXsJAQEBDAEBLwE?= =?us-ascii?q?BhD8CgmUjNgcOAQMBAQQBAQIBBm2FKoVLBidSEFFXBg4FgyKBdxSsFTOFSYM?= =?us-ascii?q?ugUiBNAGHCYRZF4FAP4ERgXCBYIURhRYEjCWKEpRpCYIdlBIMG5gppTcCERW?= =?us-ascii?q?BVwEwgVhNIxWDJ4JNAReOIz0BATGNGwGBIAEB?= X-IronPort-AV: E=Sophos;i="5.64,349,1559520000"; d="scan'208";a="312670716" Received: from rcdn-core-10.cisco.com ([173.37.93.146]) by alln-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 05 Aug 2019 09:08:01 +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 x75981ZA023221 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=FAIL) for ; Mon, 5 Aug 2019 09:08:01 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 04:08:00 -0500 From: Jakub Grajciar To: CC: Jakub Grajciar Date: Mon, 5 Aug 2019 11:07:32 +0200 Message-ID: <20190805090732.26370-1-jgrajcia@cisco.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805084806.4320-1-jgrajcia@cisco.com> References: <20190805084806.4320-1-jgrajcia@cisco.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.61.250.185] X-ClientProxiedBy: xch-aln-006.cisco.com (173.36.7.16) 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 v2] 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(-) V2: - fix coding style diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c index 01a935f87..137033f68 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