Change in osmo-bts[master]: cbch: Fix dangling cur_msg leading to double-free in bts_cbch_reset()

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/.

laforge gerrit-no-reply at lists.osmocom.org
Wed Nov 24 19:18:28 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/26351 )

Change subject: cbch: Fix dangling cur_msg leading to double-free in bts_cbch_reset()
......................................................................

cbch: Fix dangling cur_msg leading to double-free in bts_cbch_reset()

If a new default message is installed via RSL, and the old default
message is currently being transmitted, we must set cur_msg to NULL.

The old default message must be talloc_free()d unconditionally whenever
a new default message is being set.

We can do that by using the TALLOC_FREE macro.

Change-Id: Id32c2074b61cd1f09957b9d1558ffb3a7691a8e0
Related: OS#5325
---
M src/common/cbch.c
1 file changed, 3 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/cbch.c b/src/common/cbch.c
index a3e1296..f1f8b6a 100644
--- a/src/common/cbch.c
+++ b/src/common/cbch.c
@@ -233,10 +233,10 @@
 		rate_ctr_inc2(bts_ss->ctrs, CBCH_CTR_RCVD_QUEUED);
 		break;
 	case RSL_CB_CMD_TYPE_DEFAULT:
-		/* old default msg will be free'd in get_smscb_block() if it is currently in transit
-		 * and we set a new default_msg here */
+		/* clear the cur_msg pointer if it is the old default message */
 		if (bts_ss->cur_msg && bts_ss->cur_msg == bts_ss->default_msg)
-			talloc_free(bts_ss->cur_msg);
+			bts_ss->cur_msg = NULL;
+		talloc_free(bts_ss->default_msg);
 		if (cmd_type.def_bcast == RSL_CB_CMD_DEFBCAST_NORMAL)
 			/* def_bcast == 0: normal message */
 			bts_ss->default_msg = scm;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/26351
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Id32c2074b61cd1f09957b9d1558ffb3a7691a8e0
Gerrit-Change-Number: 26351
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211124/33b29bd5/attachment.htm>


More information about the gerrit-log mailing list