diff options
author | Matias Elo <matias.elo@nokia.com> | 2023-05-30 17:09:48 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2023-05-31 11:24:16 +0300 |
commit | 45ac01d900b42030eaaaed0499c457d1b16f0215 (patch) | |
tree | 306f5b239f923aa5e2db0eec8a77a55b10cd0184 | |
parent | 0024e3660c61e91acd5ac571ca39b5ffeac21dab (diff) |
linux-gen: timer: check capability limits in odp_timer_res_capability()
Check that capability limits are not exceeded in odp_timer_res_capability()
implementation.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
-rw-r--r-- | platform/linux-generic/odp_timer.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 4ffbf0d32..7ec1dbf80 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -1335,14 +1335,26 @@ int odp_timer_res_capability(odp_timer_clk_src_t clk_src, } if (res_capa->min_tmo) { - _ODP_ERR("Only res_ns or max_tmo based quaries supported\n"); + _ODP_ERR("Only res_ns or max_tmo based queries supported\n"); return -1; } if (res_capa->res_ns || res_capa->res_hz) { + if (res_capa->res_ns && res_capa->res_ns < timer_global->highest_res_ns) { + _ODP_DBG("Timeout resolution capability (res_ns) exceeded\n"); + return -1; + } + if (res_capa->res_hz && res_capa->res_hz > timer_global->highest_res_hz) { + _ODP_DBG("Timeout resolution capability (res_hz) exceeded\n"); + return -1; + } res_capa->min_tmo = 0; res_capa->max_tmo = MAX_TMO_NSEC; } else { /* max_tmo */ + if (res_capa->max_tmo > MAX_TMO_NSEC) { + _ODP_DBG("Maximum relative timeout capability (max_tmo) exceeded\n"); + return -1; + } res_capa->min_tmo = 0; res_capa->res_ns = timer_global->highest_res_ns; res_capa->res_hz = timer_global->highest_res_hz; |