From 10dd73cf6afdc0ba237022510ec702a56237d7d7 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 10 Oct 2014 17:24:34 +0200 Subject: bssgp: Free msgb in case of error when calling into gprs_ns_sendmsg In the OsmoSGSN we have a crash with a DEAD/BLOCKED GPRS-NS and segmented SN-UNITDATA. For the caller it is not easy to know if the passed msg buffer has been freed or not. The most easy solution is to always take the ownership and either pass it on or free it in case of an error. Adjust indirect and direct callers of gprs_ns_sendmsg. I found the following call-chains with an external msgb parameter. gprs_ns_sendmsg <- _bssgp_tx_dl_ud <- bssgp_fc_in <- bssgp_tx_dl_ud Update the test to allocate a real msgb because for the test with '1000' we will msgb_free it right away. Sponsored-by: On-Waves ehf --- src/gb/gprs_bssgp.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gb') diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 0e9fd388..7a5d6285 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -696,6 +696,7 @@ int bssgp_fc_in(struct bssgp_flow_control *fc, struct msgb *msg, LOGP(DBSSGP, LOGL_NOTICE, "Single PDU (size=%u) is larger " "than maximum bucket size (%u)!\n", llc_pdu_len, fc->bucket_size_max); + msgb_free(msg); return -EIO; } @@ -1039,6 +1040,7 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, if (bvci <= BVCI_PTM ) { LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to BVCI %u\n", bvci); + msgb_free(msg); return -EINVAL; } @@ -1046,6 +1048,7 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, if (!bctx) { LOGP(DBSSGP, LOGL_ERROR, "Cannot send DL-UD to unknown BVCI %u\n", bvci); + msgb_free(msg); return -ENODEV; } -- cgit v1.2.3