gmm: Free allocated GMMEs when freeing main context

Change-Id: I092b2d133467d1c2dcb8dfe5def99d49807b6273
This commit is contained in:
Pau Espin 2023-03-29 18:36:53 +02:00
parent 1b2ff8be92
commit 0bd994ee70
1 changed files with 11 additions and 1 deletions

View File

@ -78,6 +78,16 @@ static struct osmo_tdef T_defs_gmm[] = {
{ 0 } /* empty item at the end */
};
static void gprs_gmm_ctx_free(void)
{
struct gprs_gmm_entity *gmme;
while ((gmme = llist_first_entry_or_null(&g_ctx->gmme_list, struct gprs_gmm_entity, list)))
gprs_gmm_gmme_free(gmme);
talloc_free(g_ctx);
}
int osmo_gprs_gmm_init(enum osmo_gprs_gmm_location location)
{
bool first_init = true;
@ -86,7 +96,7 @@ int osmo_gprs_gmm_init(enum osmo_gprs_gmm_location location)
if (g_ctx) {
first_init = false;
talloc_free(g_ctx);
gprs_gmm_ctx_free();
}
g_ctx = talloc_zero(NULL, struct gprs_gmm_ctx);