aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-03-29 18:10:56 +0200
committerStefan Sperling <ssperling@sysmocom.de>2018-03-29 18:17:00 +0200
commit8f8401453cde2369c10a39e665abf566d4de1a81 (patch)
tree7ef2cc4bad3d788c34771ffb94a675136a4ae644
parent70e7f21cb1748dbc766361d139d8854f7f63ceb0 (diff)
more robust usage of osmo_timer API for osmo-hlr luop timer
Use osmo_timer_setup() to set up the luop timer, instead of settting the timer up manually. Delete the timer before the luop is freed to prevent a potential crash in case the timer is already armed and the function call chain leading up to lu_op_free() does not cancel the timer. Found while studying code to prepare work on issue OS#2785. This change has been tested with 'make check' and TTCN3 HLR tests. Related: OS#2785 Change-Id: I1a7596675b2d94217895f0f3d3f67b86ef123c2e
-rw-r--r--src/luop.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/luop.c b/src/luop.c
index 4ef4ea3..02c41d0 100644
--- a/src/luop.c
+++ b/src/luop.c
@@ -108,8 +108,7 @@ struct lu_operation *lu_op_alloc(struct osmo_gsup_server *srv)
luop = talloc_zero(srv, struct lu_operation);
OSMO_ASSERT(luop);
luop->gsup_server = srv;
- luop->timer.cb = lu_op_timer_cb;
- luop->timer.data = luop;
+ osmo_timer_setup(&luop->timer, lu_op_timer_cb, luop);
return luop;
}
@@ -119,6 +118,10 @@ void lu_op_free(struct lu_operation *luop)
/* Only attempt to remove when it was ever added to a list. */
if (luop->list.next)
llist_del(&luop->list);
+
+ /* Delete timer just in case it is still pending. */
+ osmo_timer_del(&luop->timer);
+
talloc_free(luop);
}