[dpdk-dev] [PATCH 2/6] lib: fix argument cannot be negative

Harman Kalra hkalra at marvell.com
Mon Nov 1 18:53:33 CET 2021


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 at 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



More information about the dev mailing list