summaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-01-30 11:57:25 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-01-30 21:33:29 +0100
commit4b2d02d0372ae5dc88d97b06f5cfa92841cbf036 (patch)
treea323467523b224769cf1cb4047d86d33f473bfe4 /openbsc/tests
parentbaf0f94a7dd858eba37548253959747838b1cc16 (diff)
sgsn/test: Fix memory leak in test_subscriber_gsup
Currently the MM context is not deleted when a GSUP location cancellation message is processed, because the real sgsn_update_subscriber_data function has been wrapped to a dummy implementation. This commit adds an explicit call to sgsn_mm_ctx_cleanup_free which also unassigns the LLME, so the call to gprs_llgmm_assign is removed. It also adds an assertion to check that there are no talloc'ed blocks left in tall_bsc_ctx. Addresses: == 372 bytes in 1 blocks are possibly lost in loss record 7 of 9 == at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) == by 0x4059FB8: _talloc_zero (talloc.c:354) == by 0x8055B82: sgsn_mm_ctx_alloc (gprs_sgsn.c:167) == by 0x804A336: alloc_mm_ctx (sgsn_test.c:140) == by 0x804B24D: test_subscriber_gsup (sgsn_test.c:503) == by 0x804EC99: main (sgsn_test.c:1853) Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 5e74b0e..425cf63 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -383,7 +383,6 @@ static void test_subscriber_gsup(void)
struct sgsn_mm_ctx *ctx;
struct gprs_ra_id raid = { 0, };
uint32_t local_tlli = 0xffeeddcc;
- struct gprs_llc_llme *llme;
int rc;
static const uint8_t send_auth_info_res[] = {
@@ -495,7 +494,6 @@ static void test_subscriber_gsup(void)
/* Create a context */
OSMO_ASSERT(count(gprs_llme_list()) == 0);
ctx = alloc_mm_ctx(local_tlli, &raid);
- llme = ctx->llme;
/* Attach s1 to ctx */
ctx->subscr = subscr_get(s1);
@@ -582,10 +580,11 @@ static void test_subscriber_gsup(void)
OSMO_ASSERT(!(s1->flags & GPRS_SUBSCRIBER_ENABLE_PURGE));
/* Free MM context and subscriber */
+ OSMO_ASSERT(ctx->subscr == NULL);
+ sgsn_mm_ctx_cleanup_free(ctx);
subscr_put(s1);
s1found = gprs_subscr_get_by_imsi(imsi1);
OSMO_ASSERT(s1found == NULL);
- gprs_llgmm_assign(llme, local_tlli, 0xffffffff, GPRS_ALGO_GEA0, NULL);
/* Inject PurgeMsRes GSUP message */
rc = rx_gsup_message(purge_ms_res,
@@ -1834,9 +1833,12 @@ static struct log_info info = {
int main(int argc, char **argv)
{
+ void *osmo_sgsn_ctx;
+
osmo_init_logging(&info);
- tall_bsc_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
- tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb");
+ osmo_sgsn_ctx = talloc_named_const(NULL, 0, "osmo_sgsn");
+ tall_bsc_ctx = talloc_named_const(osmo_sgsn_ctx, 0, "bsc");
+ tall_msgb_ctx = talloc_named_const(osmo_sgsn_ctx, 0, "msgb");
sgsn_auth_init();
gprs_subscr_init(sgsn);
@@ -1863,8 +1865,9 @@ int main(int argc, char **argv)
test_gmm_ptmsi_allocation();
printf("Done\n");
- talloc_report_full(tall_bsc_ctx, stderr);
+ talloc_report_full(osmo_sgsn_ctx, stderr);
OSMO_ASSERT(talloc_total_blocks(tall_msgb_ctx) == 1);
+ OSMO_ASSERT(talloc_total_blocks(tall_bsc_ctx) == 1);
return 0;
}