fix memory leaks when osmo_wqueue_enqueue() fails

Related: OS#5329
This commit is contained in:
Harald Welte 2021-11-25 15:49:52 +01:00
parent 20616fe316
commit 20d20c8da1
1 changed files with 6 additions and 1 deletions

View File

@ -48,7 +48,10 @@ int tcap_tco_n_notice_ind(struct tcap_transport_entity *se);
static int tcap_tp_udp_unitdata_req(struct tcap_transport_entity *se, struct msgb *msg)
{
return osmo_wqueue_enqueue(&se->udp.write_queue, msg);
int rc = osmo_wqueue_enqueue(&se->udp.write_queue, msg);
if (rc < 0)
msgb_free(msg);
return rc;
}
/* called by the write queue / FD magic in case we need to write a message */
@ -138,6 +141,8 @@ int tcap_scXp_n_unitdata_req(struct tcap_transport_entity *se, struct msgb *msg)
switch (se->type) {
case SCXP_T_UDP:
rc = osmo_wqueue_enqueue(&se->udp.write_queue, msg);
if (rc < 0)
msgb_free(msg);
break;
}