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 <erik.g.carrillo@intel.com>
This commit is contained in:
Erik Gabriel Carrillo 2019-07-15 10:39:31 -05:00 committed by Thomas Monjalon
parent faa4ee7536
commit c485a5e65a

@ -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 */