aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2024-01-18 13:21:23 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2024-01-19 18:23:01 +0100
commit174ad38ca511c18d5afc6da7e2e4dd063fdfadd6 (patch)
treef777ec185057b0fd6f8b0a9042fd76de4391d1b4 /src
parentd397129ebafc4b23f26f5537b0e5dce2a9b481eb (diff)
Prevent memory leaks / double free of msgb in proto_clnt.c
Diffstat (limited to 'src')
-rw-r--r--src/proto_clnt.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/proto_clnt.c b/src/proto_clnt.c
index 854b958..cfa9ca2 100644
--- a/src/proto_clnt.c
+++ b/src/proto_clnt.c
@@ -190,10 +190,13 @@ _e1dp_client_query_base(struct osmo_e1dp_client *clnt,
}
rc = osmo_e1dp_send(&clnt->ctl_fd, msgb, -1);
- if (rc < 0)
+ if (rc < 0) {
+ msgb_free(msgb);
return rc;
+ }
msgb_free(msgb);
+ msgb = NULL;
/* Response */
int flags = fcntl(clnt->ctl_fd.fd, F_GETFL, 0);
@@ -386,8 +389,10 @@ osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
if (rc)
return rc;
- if (msgb_l2len(msgb) != sizeof(struct osmo_e1dp_line_info))
+ if (msgb_l2len(msgb) != sizeof(struct osmo_e1dp_line_info)) {
+ msgb_free(msgb);
return -EPIPE;
+ }
msgb_free(msgb);
@@ -417,6 +422,11 @@ osmo_e1dp_client_set_sa_bits(struct osmo_e1dp_client *clnt, uint8_t intf, uint8_
if (rc)
return rc;
+ if (msgb_l2len(msgb) != 0) {
+ msgb_free(msgb);
+ return -EPIPE;
+ }
+
msgb_free(msgb);
return 0;
@@ -449,8 +459,10 @@ _client_ts_open(struct osmo_e1dp_client *clnt,
if (rc)
return rc;
- if ((tsfd < 0) || (msgb_l2len(msgb) != sizeof(struct osmo_e1dp_ts_info)))
+ if ((tsfd < 0) || (msgb_l2len(msgb) != sizeof(struct osmo_e1dp_ts_info))) {
+ msgb_free(msgb);
return -EPIPE;
+ }
msgb_free(msgb);