This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
lynxis lazus gerrit-no-reply at lists.osmocom.orgHello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/1751 to look at the new patch set (#2). tests: fix leaks by talloc ctx When using talloc with a NULL context an anonymous ctx will be created, but never freed. Found by ASAN. Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 --- M openbsc/tests/gbproxy/gbproxy_test.c M openbsc/tests/gtphub/gtphub_test.c M openbsc/tests/mgcp/mgcp_test.c M openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c M openbsc/tests/oap/oap_client_test.c M openbsc/tests/slhc/slhc_test.c M openbsc/tests/sndcp_xid/sndcp_xid_test.c M openbsc/tests/trau/trau_test.c M openbsc/tests/v42bis/v42bis_test.c M openbsc/tests/xid/xid_test.c 10 files changed, 28 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/51/1751/2 diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c index 577daa9..b251147 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.c +++ b/openbsc/tests/gbproxy/gbproxy_test.c @@ -53,6 +53,8 @@ struct llist_head *received_messages = NULL; +void *tctx = NULL; + /* override, requires '-Wl,--wrap=RAND_bytes' */ int __real_RAND_bytes(unsigned char *buf, int num); int mock_RAND_bytes(unsigned char *buf, int num); @@ -1660,7 +1662,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; @@ -2001,7 +2003,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 0; gbcfg.core_mnc = 0; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; @@ -2235,7 +2237,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; @@ -2554,7 +2556,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; @@ -2738,7 +2740,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; gbcfg.acquire_imsi = 1; @@ -3064,7 +3066,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 123; gbcfg.core_mnc = 456; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 1; gbcfg.acquire_imsi = 1; @@ -4844,7 +4846,7 @@ gbcfg.nsip_sgsn_nsei = SGSN_NSEI; gbcfg.core_mcc = 0; gbcfg.core_mnc = 0; - gbcfg.core_apn = talloc_zero_size(NULL, 100); + gbcfg.core_apn = talloc_zero_size(tctx, 100); gbcfg.core_apn_size = gprs_str_to_apn(gbcfg.core_apn, 100, "foo.bar"); gbcfg.patch_ptmsi = 0; gbcfg.acquire_imsi = 1; @@ -4936,7 +4938,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + tctx = talloc_named_const(NULL, 0, "gbproxy_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&info); log_set_use_color(osmo_stderr_target, 0); @@ -4965,6 +4968,7 @@ test_gbproxy_keep_info(); test_gbproxy_tlli_expire(); test_gbproxy_stored_messages(); + talloc_free(tctx); printf("===== GbProxy test END\n\n"); exit(EXIT_SUCCESS); diff --git a/openbsc/tests/gtphub/gtphub_test.c b/openbsc/tests/gtphub/gtphub_test.c index e7c27d2..4574ff1 100644 --- a/openbsc/tests/gtphub/gtphub_test.c +++ b/openbsc/tests/gtphub/gtphub_test.c @@ -1781,6 +1781,7 @@ talloc_report_full(osmo_gtphub_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(osmo_gtphub_ctx) == 1); + talloc_free(osmo_gtphub_ctx); return 0; } diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index b2d237e..a645f92 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -1203,7 +1203,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *mgcp_talloc = talloc_named_const(NULL, 0, "mgcp_test"); + msgb_talloc_ctx_init(mgcp_talloc, 0); osmo_init_logging(&log_info); test_strline(); @@ -1222,6 +1223,8 @@ test_no_name(); test_osmux_cid(); + talloc_free(mgcp_talloc); + printf("Done\n"); return EXIT_SUCCESS; } diff --git a/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c b/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c index ee138b8..39975e5 100644 --- a/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c +++ b/openbsc/tests/nanobts_omlattr/nanobts_omlattr_test.c @@ -273,6 +273,7 @@ talloc_free(trx); talloc_report_full(ctx, stderr); OSMO_ASSERT(talloc_total_blocks(ctx) == 1); + talloc_free(ctx); return 0; } diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c index e6501cb..a5311fc 100644 --- a/openbsc/tests/oap/oap_client_test.c +++ b/openbsc/tests/oap/oap_client_test.c @@ -252,7 +252,8 @@ int main(int argc, char **argv) { - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "oap_client_test"); + msgb_talloc_ctx_init(tctx, 0); osmo_init_logging(&info); OSMO_ASSERT(osmo_stderr_target); @@ -263,6 +264,7 @@ log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); test_oap_api(); + talloc_free(tctx); printf("Done\n"); return 0; diff --git a/openbsc/tests/slhc/slhc_test.c b/openbsc/tests/slhc/slhc_test.c index d2e1cd9..6411b35 100644 --- a/openbsc/tests/slhc/slhc_test.c +++ b/openbsc/tests/slhc/slhc_test.c @@ -261,6 +261,7 @@ talloc_report_full(ctx, stderr); OSMO_ASSERT(talloc_total_blocks(ctx) == 1); + talloc_free(ctx); return 0; } diff --git a/openbsc/tests/sndcp_xid/sndcp_xid_test.c b/openbsc/tests/sndcp_xid/sndcp_xid_test.c index 151dd2b..524afa3 100644 --- a/openbsc/tests/sndcp_xid/sndcp_xid_test.c +++ b/openbsc/tests/sndcp_xid/sndcp_xid_test.c @@ -273,6 +273,7 @@ talloc_report_full(xid_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1); + talloc_free(xid_ctx); return 0; } diff --git a/openbsc/tests/trau/trau_test.c b/openbsc/tests/trau/trau_test.c index c74e6db..3464515 100644 --- a/openbsc/tests/trau/trau_test.c +++ b/openbsc/tests/trau/trau_test.c @@ -66,7 +66,8 @@ unsigned char data[33]; int i; - msgb_talloc_ctx_init(NULL, 0); + void *tctx = talloc_named_const(NULL, 0, "trau_test"); + msgb_talloc_ctx_init(tctx, 0); memset(data, 0x00, sizeof(data)); test_trau_fr_efr(data); @@ -76,6 +77,7 @@ for (i = 0; i < sizeof(data); i++) data[i] = random(); test_trau_fr_efr(data); + talloc_free(tctx); printf("Done\n"); return 0; } diff --git a/openbsc/tests/v42bis/v42bis_test.c b/openbsc/tests/v42bis/v42bis_test.c index 7e90785..21ee421 100644 --- a/openbsc/tests/v42bis/v42bis_test.c +++ b/openbsc/tests/v42bis/v42bis_test.c @@ -424,6 +424,7 @@ printf("Done\n"); talloc_report_full(v42bis_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(v42bis_ctx) == 1); + talloc_free(v42bis_ctx); return 0; } diff --git a/openbsc/tests/xid/xid_test.c b/openbsc/tests/xid/xid_test.c index b77a4ae..de40067 100644 --- a/openbsc/tests/xid/xid_test.c +++ b/openbsc/tests/xid/xid_test.c @@ -153,6 +153,7 @@ talloc_report_full(xid_ctx, stderr); OSMO_ASSERT(talloc_total_blocks(xid_ctx) == 1); + talloc_free(xid_ctx); return 0; } -- To view, visit https://gerrit.osmocom.org/1751 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I5bba63ed4e4cf23501063dd03bf38eee9945c163 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis at fe80.eu> Gerrit-Reviewer: Jenkins Builder