]> git.droids-corp.org - dpdk.git/commitdiff
eal/linux: check interrupt file descriptor validity
authorHarman Kalra <hkalra@marvell.com>
Mon, 1 Nov 2021 17:53:33 +0000 (23:23 +0530)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 8 Nov 2021 16:32:42 +0000 (17:32 +0100)
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>
Acked-by: David Marchand <david.marchand@redhat.com>
lib/eal/linux/eal_dev.c

index 1fd00a482baf2aa8a27fafda1ae3016462cdca0e..bde55a3d929080cf6485c3a0a572fc8e921d2c76 100644 (file)
@@ -220,8 +220,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
@@ -237,6 +239,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)