summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-16 01:26:00 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-16 01:34:26 +0100
commita4952aa43625140ec7e9f2e892d938d16ee7ae88 (patch)
tree3d98a4ce64561f6806af32baf4f3681298b16a6d /src
parent90539ac30b6201a93b7c4e5b9747e603e64565af (diff)
memleak: fix all libosmocore callers of gsmtap_sendmsg() to free on failure
gsmtap_sendmsg() does not free the msgb if it returns a failure rc, so the callers must check the rc and free the msg. Change-Id: I7cf64ed9b14247298ed8b4ab8735627f8235a499
Diffstat (limited to 'src')
-rw-r--r--src/gsmtap_util.c6
-rw-r--r--src/logging_gsmtap.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 962782b5..b21c690b 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -303,6 +303,7 @@ int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_
unsigned int len)
{
struct msgb *msg;
+ int rc;
if (!gti)
return -ENODEV;
@@ -312,7 +313,10 @@ int gsmtap_send_ex(struct gsmtap_inst *gti, uint8_t type, uint16_t arfcn, uint8_
if (!msg)
return -ENOMEM;
- return gsmtap_sendmsg(gti, msg);
+ rc = gsmtap_sendmsg(gti, msg);
+ if (rc)
+ msgb_free(msg);
+ return rc;
}
/*! send a message from L1/L2 through GSMTAP.
diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index cb379b07..c53a0abe 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -103,7 +103,9 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
return;
msgb_put(msg, rc);
- gsmtap_sendmsg(target->tgt_gsmtap.gsmtap_inst, msg);
+ rc = gsmtap_sendmsg(target->tgt_gsmtap.gsmtap_inst, msg);
+ if (rc)
+ msgb_free(msg);
}
/*! Create a new logging target for GSMTAP logging