Change in libosmocore[master]: lapdm_rslms_recvmsg: Fix memory leak in error path

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue May 21 10:33:00 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/14082 )

Change subject: lapdm_rslms_recvmsg: Fix memory leak in error path
......................................................................

lapdm_rslms_recvmsg: Fix memory leak in error path

The caller of lapdm_rslms_recvmsg() (e.g. osmo-bts/src/common/rsl.c)
assumes the message ownership is transferred.  However, in one of the
two error paths, msgb_free() was not called and hence we had a memory
leak.

Also clarify the msgb ownership transfer in a comment.

Related: OS#3750
Change-Id: Id60cb45e50bfc89224d97df6c68fcd2949751895
---
M src/gsm/lapdm.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, approved



diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c
index ba9b3df..d76175b 100644
--- a/src/gsm/lapdm.c
+++ b/src/gsm/lapdm.c
@@ -1269,7 +1269,8 @@
 	return rc;
 }
 
-/*! Receive a RSLms \ref msgb from Layer 3 */
+/*! Receive a RSLms \ref msgb from Layer 3. 'msg' ownership is transferred,
+ *  i.e. caller must not free it */
 int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc)
 {
 	struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
@@ -1277,6 +1278,7 @@
 
 	if (msgb_l2len(msg) < sizeof(*rslh)) {
 		LOGP(DLLAPD, LOGL_ERROR, "Message too short RSL hdr!\n");
+		msgb_free(msg);
 		return -EINVAL;
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/14082
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id60cb45e50bfc89224d97df6c68fcd2949751895
Gerrit-Change-Number: 14082
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190521/6e8e9a12/attachment.htm>


More information about the gerrit-log mailing list