pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-pcu/+/36450?usp=email )
Change subject: Force free of tbfs upon GprsMs object free()
......................................................................
Force free of tbfs upon GprsMs object free()
Change-Id: Ibbdec94acb8132be20508d3178d88da44bfaf91d
---
M src/gprs_ms.c
M tests/ms/MsTest.cpp
2 files changed, 20 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/50/36450/1
diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 7fa3fc0..ff7316b 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -193,18 +193,18 @@
osmo_timer_del(&ms->release_timer);
if (ms->ul_tbf) {
- tbf_set_ms(ul_tbf_as_tbf(ms->ul_tbf), NULL);
- ms->ul_tbf = NULL;
+ tbf_free(ul_tbf_as_tbf(ms->ul_tbf));
+ OSMO_ASSERT(ms->ul_tbf == NULL);
}
if (ms->dl_tbf) {
- tbf_set_ms(dl_tbf_as_tbf(ms->dl_tbf), NULL);
- ms->dl_tbf = NULL;
+ tbf_free(dl_tbf_as_tbf(ms->dl_tbf));
+ OSMO_ASSERT(ms->dl_tbf == NULL);
}
llist_for_each_entry_safe(pos, tmp, &ms->old_tbfs, list) {
struct gprs_rlcmac_tbf *tbf = (struct gprs_rlcmac_tbf *)pos->entry;
- tbf_set_ms(tbf, NULL);
+ tbf_free(tbf);
}
llc_queue_clear(&ms->llc_queue, ms->bts);
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index f051401..5bfbc28 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -443,8 +443,6 @@
dl_tbf = alloc_dl_tbf(bts, ms);
ms_attach_tbf(ms, dl_tbf);
- ms_unref(ms, __func__);
-
OSMO_ASSERT(!ms_is_idle(ms));
OSMO_ASSERT(mcs_chan_code(ms_current_cs_dl(ms, ms_mode(ms))) == 3);
@@ -453,8 +451,10 @@
OSMO_ASSERT(mcs_chan_code(ms_current_cs_dl(ms, ms_mode(ms))) == 2);
- talloc_free(ms);
+ ms_detach_tbf(ms, dl_tbf);
talloc_free(dl_tbf);
+ ms_unref(ms, __func__);
+ /* MS has been freed here*/
talloc_free(bts);
printf("=== end %s ===\n", __func__);
}
@@ -513,9 +513,8 @@
ms_set_mode(ms2, EGPRS_GMSK);
dump_ms(ms2, "2: after mode set ");
- // FIXME: following code triggers ASAN failure:
- // ms2->detach_tbf(dl_tbf);
- // dump_ms(ms2, "2: after TBF detach ");
+ ms_detach_tbf(ms2, dl_tbf);
+ dump_ms(ms2, "2: after TBF detach ");
ms_set_mode(ms1, GPRS);
dump_ms(ms1, "1: after mode set ");
@@ -523,9 +522,9 @@
ms_set_mode(ms2, GPRS);
dump_ms(ms2, "2: after mode set ");
+ talloc_free(dl_tbf);
talloc_free(ms1);
talloc_free(ms2);
- talloc_free(dl_tbf);
talloc_free(bts);
printf("=== end %s ===\n", __func__);
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-pcu/+/36450?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ibbdec94acb8132be20508d3178d88da44bfaf91d
Gerrit-Change-Number: 36450
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange