sgsn: Don't reset mm->subscr manually in sgsn_mm_ctx_free
Currently the sgsn_mm_ctx_free contains code to reset the mm->subscr
field that is also present in gprs_subscr_cleanup, which is called
directly afterwards.
This commit modifies the code path, so that the cleanup is done by
the gprs_subscr_cleanup function. The additional reference counter
increment is needed, since mm->subscr->mm->subscr (which is the same
like mm->subscr) will be reset (and unref'd) within
gprs_subscr_cleanup. Because the local variable subscr in
sgsn_mm_ctx_free is an additional pointer to the subscriber object,
it is consequent to adjust the reference counter when the assignment
is done.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 490371f..781be3f 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -196,9 +196,7 @@
/* Detach from subscriber which is possibly freed then */
if (mm->subscr) {
- struct gsm_subscriber *subscr = mm->subscr;
- mm->subscr = NULL;
- subscr->sgsn_data->mm = NULL;
+ struct gsm_subscriber *subscr = subscr_get(mm->subscr);
gprs_subscr_cleanup(subscr);
subscr_put(subscr);
}