Change in osmo-bts[master]: [lc15, oc2g, octphy] Fix memory leak on write queue overflow

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

pespin gerrit-no-reply at lists.osmocom.org
Thu Nov 25 13:15:30 UTC 2021


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

Change subject: [lc15,oc2g,octphy] Fix memory leak on write queue overflow
......................................................................

[lc15,oc2g,octphy] Fix memory leak on write queue overflow

Callers of osmo_wqueue_enqueue must always check the return value
and free the message themselves in the error case.

Change-Id: Ic67fbef23e419c0c8a7bcfb16d134e1bf649de72
Related: OS#5329
---
M src/osmo-bts-lc15/l1_if.c
M src/osmo-bts-oc2g/l1_if.c
M src/osmo-bts-octphy/l1_if.c
3 files changed, 16 insertions(+), 3 deletions(-)

Approvals:
  daniel: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-lc15/l1_if.c b/src/osmo-bts-lc15/l1_if.c
index 02c8646..ac165b8 100644
--- a/src/osmo-bts-lc15/l1_if.c
+++ b/src/osmo-bts-lc15/l1_if.c
@@ -553,7 +553,12 @@
 		empty_req_from_l1sap(l1p, fl1, u8Tn, u32Fn, sapi, subCh, u8BlockNbr);
 	}
 	/* send message to DSP's queue */
-	osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg);
+	if (osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg) < 0) {
+		LOGPFN(DL1P, LOGL_ERROR, u32Fn, "MQ_L1_WRITE queue full. Dropping msg.\n");
+		msgb_free(nmsg);
+		return -ENOBUFS;
+	}
+
 	if (dtx_is_first_p1(lchan))
 		dtx_dispatch(lchan, E_FIRST);
 	else
diff --git a/src/osmo-bts-oc2g/l1_if.c b/src/osmo-bts-oc2g/l1_if.c
index 2cefc3b..194f82a 100644
--- a/src/osmo-bts-oc2g/l1_if.c
+++ b/src/osmo-bts-oc2g/l1_if.c
@@ -606,7 +606,11 @@
 		empty_req_from_l1sap(l1p, fl1, u8Tn, u32Fn, sapi, subCh, u8BlockNbr);
 	}
 	/* send message to DSP's queue */
-	osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg);
+	if (osmo_wqueue_enqueue(&fl1->write_q[MQ_L1_WRITE], nmsg) < 0) {
+		LOGPFN(DL1P, LOGL_ERROR, u32Fn, "MQ_L1_WRITE queue full. Dropping msg.\n");
+		msgb_free(nmsg);
+		return -ENOBUFS;
+	}
 	if (dtx_is_first_p1(lchan))
 		dtx_dispatch(lchan, E_FIRST);
 	else
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 294a65e..ebd960e 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -1302,7 +1302,11 @@
 			wlc->num_retrans++;
 			msg = msgb_copy(wlc->cmd_msg, "PHY CMD Retrans");
 			msg_set_retrans_flag(msg);
-			osmo_wqueue_enqueue(&fl1h->phy_wq, msg);
+			if (osmo_wqueue_enqueue(&fl1h->phy_wq, msg) < 0) {
+				LOGP(DL1C, LOGL_ERROR, "Queue full on wlc retransmit\n");
+				msgb_free(msg);
+				return 0;
+			}
 			osmo_timer_schedule(&wlc->timer, CMD_TIMEOUT, 0);
 			count++;
 			LOGP(DL1C, LOGL_INFO, "Re-transmitting %s "

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ic67fbef23e419c0c8a7bcfb16d134e1bf649de72
Gerrit-Change-Number: 26362
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
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/20211125/5293fc39/attachment.htm>


More information about the gerrit-log mailing list