DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jakub Grajciar <jgrajcia@cisco.com>
To: <dev@dpdk.org>
Cc: Jakub Grajciar <jgrajcia@cisco.com>
Subject: [dpdk-dev] [PATCH v2] net/memif: fix coverity defects
Date: Mon, 5 Aug 2019 11:07:32 +0200	[thread overview]
Message-ID: <20190805090732.26370-1-jgrajcia@cisco.com> (raw)
In-Reply-To: <20190805084806.4320-1-jgrajcia@cisco.com>

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

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

  reply	other threads:[~2019-08-05  9:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05  8:48 [dpdk-dev] [PATCH] " Jakub Grajciar
2019-08-05  9:07 ` Jakub Grajciar [this message]
2019-08-06  8:26   ` [dpdk-dev] [PATCH v2] " Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190805090732.26370-1-jgrajcia@cisco.com \
    --to=jgrajcia@cisco.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).