If we don't do this, we will generate a bogus warning in
gprs_sgsn:sgsn_pdp_ctx_free() when we release a pctx which still has the
lib pointer set to non-NULL.
At the same point, we introduce an OSMO_ASSERT() to verify that the
pctx->lib really equals the pdp context which libgtp reported to us.
---
openbsc/src/gprs/sgsn_libgtp.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c
index f2eb35d..c244e2c 100644
--- a/openbsc/src/gprs/sgsn_libgtp.c
+++ b/openbsc/src/gprs/sgsn_libgtp.c
@@ -264,6 +264,10 @@ static int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause)
DEBUGP(DGPRS, "Received CREATE PDP CTX CONF, cause=%d(%s)\n",
cause, get_value_string(gtp_cause_strs, cause));
+ /* make sure that libgtp doesn't call us with inconsistent
+ * pointers */
+ OSMO_ASSERT(pctx->lib == pdp);
+
/* Check for cause value if it was really successful */
if (cause < 0) {
LOGP(DGPRS, LOGL_NOTICE, "Create PDP ctx req timed out\n");
@@ -292,8 +296,13 @@ static int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause)
reject:
pctx->state = PDP_STATE_NONE;
- if (pdp)
+ if (pdp) {
pdp_freepdp(pdp);
+ /* unlink the now non-existing library handle from the
+ * pdp context */
+ pctx->lib = NULL;
+ }
+
/* Send PDP CTX ACT REJ to MS */
rc = gsm48_tx_gsm_act_pdp_rej(pctx->mm, pctx->ti, reject_cause,
0, NULL);
--
1.8.3.2
--
- Harald Welte <laforge(a)gnumonks.org>
http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
(ETSI EN 300 175-7 Ch. A6)