From: Yunjian Wang Date: Thu, 15 Oct 2020 08:42:30 +0000 (+0800) Subject: eal: fix interrupt trace point X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=39e2961a0938fe80c943e6188765f3792dce9dfb;p=dpdk.git eal: fix interrupt trace point This patch fixes (dereference after null check) coverity issue. For this reason, we should add null check at the beginning of the function and return error directly if the 'intr_handle' is null. Coverity issue: 357695, 357751 Fixes: 05c4105738d8 ("trace: add interrupt tracepoints") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Reviewed-by: Harman Kalra --- diff --git a/lib/librte_eal/freebsd/eal_interrupts.c b/lib/librte_eal/freebsd/eal_interrupts.c index b07cff6393..72eeacbc14 100644 --- a/lib/librte_eal/freebsd/eal_interrupts.c +++ b/lib/librte_eal/freebsd/eal_interrupts.c @@ -350,13 +350,15 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle) { int rc = 0; - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { + if (intr_handle == NULL) + return -1; + + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { rc = 0; goto out; } - if (!intr_handle || intr_handle->fd < 0 || - intr_handle->uio_cfg_fd < 0) { + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { rc = -1; goto out; } @@ -389,13 +391,15 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle) { int rc = 0; - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { + if (intr_handle == NULL) + return -1; + + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { rc = 0; goto out; } - if (!intr_handle || intr_handle->fd < 0 || - intr_handle->uio_cfg_fd < 0) { + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { rc = -1; goto out; } diff --git a/lib/librte_eal/linux/eal_interrupts.c b/lib/librte_eal/linux/eal_interrupts.c index 26b5dd4ca8..2f03a61254 100644 --- a/lib/librte_eal/linux/eal_interrupts.c +++ b/lib/librte_eal/linux/eal_interrupts.c @@ -667,13 +667,15 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle) { int rc = 0; - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { + if (intr_handle == NULL) + return -1; + + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { rc = 0; goto out; } - if (!intr_handle || intr_handle->fd < 0 || - intr_handle->uio_cfg_fd < 0) { + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { rc = -1; goto out; } @@ -794,13 +796,15 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle) { int rc = 0; - if (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV) { + if (intr_handle == NULL) + return -1; + + if (intr_handle->type == RTE_INTR_HANDLE_VDEV) { rc = 0; goto out; } - if (!intr_handle || intr_handle->fd < 0 || - intr_handle->uio_cfg_fd < 0) { + if (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) { rc = -1; goto out; }