[v2] net/memif: fix coverity defects
diff mbox series

Message ID 20190805090732.26370-1-jgrajcia@cisco.com
State Accepted, archived
Headers show
Series
  • [v2] net/memif: fix coverity defects
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

fixes CID: 343440, 343459, 343464, 343394

Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
---
 drivers/net/memif/memif_socket.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

V2:
- fix coding style

--
2.17.1

Comments

Thomas Monjalon Aug. 6, 2019, 8:26 a.m. UTC | #1
05/08/2019 11:07, Jakub Grajciar:
> fixes CID: 343440, 343459, 343464, 343394
> 
> Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>

Commit message fixed:

    net/memif: fix error paths
    
    Coverity issue: 343440, 343459, 343464, 343394
    Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")

Applied

Patch
diff mbox series

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;
 	}