[PATCH] libbsc: fix message leaks on several error paths

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/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Tue Oct 16 16:23:17 UTC 2012


From: Pablo Neira Ayuso <pablo at gnumonks.org>

This patch fixes several leak of msgbs in uncommon error paths.
---
 openbsc/src/libbsc/abis_nm.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c
index ee0dd60..2c8b3ee 100644
--- a/openbsc/src/libbsc/abis_nm.c
+++ b/openbsc/src/libbsc/abis_nm.c
@@ -635,13 +635,16 @@ int abis_nm_rcvmsg(struct msgb *msg)
 	if (oh->placement != ABIS_OM_PLACEMENT_ONLY) {
 		LOGP(DNM, LOGL_ERROR, "ABIS OML placement 0x%x not supported\n",
 			oh->placement);
-		if (oh->placement != ABIS_OM_PLACEMENT_FIRST)
-			return -EINVAL;
+		if (oh->placement != ABIS_OM_PLACEMENT_FIRST) {
+			rc = -EINVAL;
+			goto err;
+		}
 	}
 	if (oh->sequence != 0) {
 		LOGP(DNM, LOGL_ERROR, "ABIS OML sequence 0x%x != 0x00\n",
 			oh->sequence);
-		return -EINVAL;
+		rc = -EINVAL;
+		goto err;
 	}
 #if 0
 	unsigned int l2_len = msg->tail - (uint8_t *)msgb_l2(msg);
@@ -671,9 +674,9 @@ int abis_nm_rcvmsg(struct msgb *msg)
 	default:
 		LOGP(DNM, LOGL_ERROR, "unknown ABIS OML message discriminator 0x%x\n",
 			oh->mdisc);
-		return -EINVAL;
+		rc = -EINVAL;
 	}
-
+err:
 	msgb_free(msg);
 	return rc;
 }
-- 
1.7.10.4





More information about the OpenBSC mailing list