ms: Hold a reference during ms_alloc

Make the caller hold a reference to the MS object just allocated, so
that it hs to explicitly unref it and, in turn, if no new references
were added during its use, trigger release of the MS object.
This is useful to avoid leaking MS object if it was allocated and then
no TBF is attached to it because allocation of TBF failed.

Related: OS#6002
Change-Id: I2088a7ddd76fe9157b6626ef96ae4315e88779ea
diff --git a/src/gprs_ms.c b/src/gprs_ms.c
index 6d7018f..7df71e8 100644
--- a/src/gprs_ms.c
+++ b/src/gprs_ms.c
@@ -122,7 +122,7 @@
 }
 
 static int ms_talloc_destructor(struct GprsMs *ms);
-struct GprsMs *ms_alloc(struct gprs_rlcmac_bts *bts)
+struct GprsMs *ms_alloc(struct gprs_rlcmac_bts *bts, const char *use_ref)
 {
 	struct GprsMs *ms = talloc_zero(tall_pcu_ctx, struct GprsMs);
 	OSMO_ASSERT(bts);
@@ -172,6 +172,8 @@
 
 	ms_set_timeout(ms, osmo_tdef_get(bts->pcu->T_defs, -2030, OSMO_TDEF_S, -1));
 
+	if (use_ref)
+		ms_ref(ms, use_ref);
 	return ms;
 free_ret:
 	talloc_free(ms);