summaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-03-28 18:09:31 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-03-28 18:13:37 +0100
commitfd603ed9e2f87d05b2261a25e11aceb01814dfbe (patch)
treec073912edaaa0fd00e6e43131231e8994eb28539 /openbsc
parentcf7557a7e756af54350fb9bcf1a19429848a17de (diff)
write_queue: Check the result of osmo_wqueue_enqueue and free
The write_queue is designed to have a maximum amount of pending messages and will refuse to take new messages when it has been reached. The caller can decide if it wants to flush the queue and add the message again, create a log. But in all cases the ownership of the msgb has not been transferred. Fix the potential memory leak in the failure situation.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/libmsc/meas_feed.c3
-rw-r--r--openbsc/src/libmsc/smpp_smsc.c8
-rw-r--r--openbsc/src/utils/smpp_mirror.c8
3 files changed, 16 insertions, 3 deletions
diff --git a/openbsc/src/libmsc/meas_feed.c b/openbsc/src/libmsc/meas_feed.c
index 86ba3b712..86d679abf 100644
--- a/openbsc/src/libmsc/meas_feed.c
+++ b/openbsc/src/libmsc/meas_feed.c
@@ -61,7 +61,8 @@ static int process_meas_rep(struct gsm_meas_rep *mr)
memcpy(&mfm->mr, mr, sizeof(mfm->mr));
/* and send it to the socket */
- osmo_wqueue_enqueue(&g_mfs.wqueue, msg);
+ if (osmo_wqueue_enqueue(&g_mfs.wqueue, msg) != 0)
+ msgb_free(msg);
return 0;
}
diff --git a/openbsc/src/libmsc/smpp_smsc.c b/openbsc/src/libmsc/smpp_smsc.c
index 048c1b802..c1ec22f5b 100644
--- a/openbsc/src/libmsc/smpp_smsc.c
+++ b/openbsc/src/libmsc/smpp_smsc.c
@@ -352,7 +352,13 @@ static int pack_and_send(struct osmo_esme *esme, uint32_t type, void *ptr)
}
msgb_put(msg, rlen);
- return osmo_wqueue_enqueue(&esme->wqueue, msg);
+ if (osmo_wqueue_enqueue(&esme->wqueue, msg) != 0) {
+ LOGP(DSMPP, LOGL_ERROR, "[%s] Write queue full. Dropping message\n",
+ esme->system_id);
+ msgb_free(msg);
+ return -EAGAIN;
+ }
+ return 0;
}
/*! \brief transmit a generic NACK to a remote ESME */
diff --git a/openbsc/src/utils/smpp_mirror.c b/openbsc/src/utils/smpp_mirror.c
index cf3657e39..2f154db49 100644
--- a/openbsc/src/utils/smpp_mirror.c
+++ b/openbsc/src/utils/smpp_mirror.c
@@ -85,7 +85,13 @@ static int pack_and_send(struct esme *esme, uint32_t type, void *ptr)
}
msgb_put(msg, rlen);
- return osmo_wqueue_enqueue(&esme->wqueue, msg);
+ if (osmo_wqueue_enqueue(&esme->wqueue, msg) != 0) {
+ LOGP(DSMPP, LOGL_ERROR, "[%s] Write queue full. Dropping message\n",
+ esme->system_id);
+ msgb_free(msg);
+ return -EAGAIN;
+ }
+ return 0;
}
/* FIXME: merge with smpp_smsc.c */