[2/6] lib: fix argument cannot be negative
Checks
Commit Message
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(-)
@@ -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)