From c485a5e65a641b64e2bcd2959aa151e6278be0c4 Mon Sep 17 00:00:00 2001 From: Erik Gabriel Carrillo Date: Mon, 15 Jul 2019 10:39:31 -0500 Subject: [PATCH] timer: fix null access if not initialized If the timer subsystem is not initialized before rte_timer_manage (for example) is invoked, a pointer to a shared hugepage memory region will still be null and dereferenced when it is checked for validity; handle this case. Fixes: c0749f7096c7 ("timer: allow management in shared memory") Cc: stable@dpdk.org Signed-off-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 71dffd23bf..bdcf05d06b 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -85,7 +85,8 @@ static struct rte_timer_data default_timer_data; static inline int timer_data_valid(uint32_t id) { - return !!(rte_timer_data_arr[id].internal_flags & FL_ALLOCATED); + return rte_timer_data_arr && + (rte_timer_data_arr[id].internal_flags & FL_ALLOCATED); } /* validate ID and retrieve timer data pointer, or return error value */ -- 2.20.1