aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2023-06-05 17:15:01 +0300
committerMatias Elo <matias.elo@nokia.com>2023-08-08 09:54:40 +0300
commitc6b21e7a635dc4f7ee7c36500ccac8a8f1b7f402 (patch)
tree959aaaa3cfca24a14fa66deb929c69d74c810cfa
parentda1356ff503a7491018ab40181826fa8f4e13efd (diff)
Port 13918e69c "linux-gen: timer: fix odp_timeout_fresh() crash"
Port original commit from linux-generic. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
-rw-r--r--platform/linux-dpdk/odp_timer.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/platform/linux-dpdk/odp_timer.c b/platform/linux-dpdk/odp_timer.c
index 1021a96cd..eb5eed88a 100644
--- a/platform/linux-dpdk/odp_timer.c
+++ b/platform/linux-dpdk/odp_timer.c
@@ -1228,8 +1228,14 @@ uint64_t odp_timeout_to_u64(odp_timeout_t tmo)
int odp_timeout_fresh(odp_timeout_t tmo)
{
+ timer_entry_t *timer;
odp_timeout_hdr_t *timeout_hdr = timeout_to_hdr(tmo);
- timer_entry_t *timer = timer_from_hdl(timeout_hdr->timer);
+
+ /* Timeout not connected to a timer */
+ if (odp_unlikely(timeout_hdr->timer == ODP_TIMER_INVALID))
+ return 0;
+
+ timer = timer_from_hdl(timeout_hdr->timer);
if (timer->timer_pool->periodic)
return timer->periodic_ticks != PERIODIC_CANCELLED;
@@ -1240,6 +1246,7 @@ int odp_timeout_fresh(odp_timeout_t tmo)
odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl)
{
+ odp_timeout_hdr_t *timeout_hdr;
odp_event_t event;
pool_t *pool;
@@ -1253,6 +1260,9 @@ odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl)
if (odp_unlikely(event == ODP_EVENT_INVALID))
return ODP_TIMEOUT_INVALID;
+ timeout_hdr = timeout_to_hdr(odp_timeout_from_event(event));
+ timeout_hdr->timer = ODP_TIMER_INVALID;
+
return odp_timeout_from_event(event);
}