DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harman Kalra <hkalra@marvell.com>
To: <dev@dpdk.org>
Cc: <david.marchand@redhat.com>, <john.mcnamara@intel.com>,
	Harman Kalra <hkalra@marvell.com>
Subject: [dpdk-dev] [PATCH 2/6] lib: fix argument cannot be negative
Date: Mon, 1 Nov 2021 23:23:33 +0530	[thread overview]
Message-ID: <20211101175337.83358-2-hkalra@marvell.com> (raw)
In-Reply-To: <20211101175337.83358-1-hkalra@marvell.com>

This patch fixes coverity issue by adding a check for
negative event fd value.

Coverity issue: 373711,373694
Fixes: c2bd9367e18f ("lib: remove direct access to interrupt handle")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
---
 lib/eal/linux/eal_dev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c
index 06820a3666..607f18ebc2 100644
--- a/lib/eal/linux/eal_dev.c
+++ b/lib/eal/linux/eal_dev.c
@@ -217,8 +217,10 @@ static void
 dev_delayed_unregister(void *param)
 {
 	rte_intr_callback_unregister(intr_handle, dev_uev_handler, param);
-	close(rte_intr_fd_get(intr_handle));
-	rte_intr_fd_set(intr_handle, -1);
+	if (rte_intr_fd_get(intr_handle) >= 0) {
+		close(rte_intr_fd_get(intr_handle));
+		rte_intr_fd_set(intr_handle, -1);
+	}
 }
 
 static void
@@ -234,6 +236,9 @@ dev_uev_handler(__rte_unused void *param)
 	memset(&uevent, 0, sizeof(struct rte_dev_event));
 	memset(buf, 0, EAL_UEV_MSG_LEN);
 
+	if (rte_intr_fd_get(intr_handle) < 0)
+		return;
+
 	ret = recv(rte_intr_fd_get(intr_handle), buf, EAL_UEV_MSG_LEN,
 		   MSG_DONTWAIT);
 	if (ret < 0 && errno == EAGAIN)
-- 
2.18.0


  reply	other threads:[~2021-11-01 17:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 17:53 [dpdk-dev] [PATCH 1/6] interrupts: " Harman Kalra
2021-11-01 17:53 ` Harman Kalra [this message]
2021-11-01 17:53 ` [dpdk-dev] [PATCH 3/6] drivers: fix bad bit shift operation Harman Kalra
2021-11-02  1:22   ` Wang, Haiyue
2021-11-01 17:53 ` [dpdk-dev] [PATCH 4/6] drivers: fix argument cannot be negative Harman Kalra
2021-11-01 17:53 ` [dpdk-dev] [PATCH 5/6] drivers: fix improper use of negative value Harman Kalra
2021-11-01 17:53 ` [dpdk-dev] [PATCH 6/6] net/mlx4: fix dereference after null check Harman Kalra
2021-11-02  7:34   ` Slava Ovsiienko
2021-11-08 16:32     ` David Marchand

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=20211101175337.83358-2-hkalra@marvell.com \
    --to=hkalra@marvell.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=john.mcnamara@intel.com \
    /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).