From 14b7311bd8f65a3447ce884bd15707031d6e6128 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Tue, 6 Aug 2024 17:11:36 +0200 Subject: [PATCH] Fix memory leak in do_NR_ULInformationTransfer * buffer is allocated but not freed after use by PDCP > Direct leak of 192 byte(s) in 3 object(s) allocated from: > 0 0x7ffff74b4c38 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164 > 1 0x55555775ee74 in encode_dyn_cb /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/per_encoder.c:23 > 2 0x55555774776e in _uper_encode_flush_outp /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/uper_encoder.c:126 > 3 0x55555774776e in uper_encode /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/uper_encoder.c:36 > 4 0x555557747c91 in uper_encode_to_new_buffer /cmake_targets/ran_build/build/openair2/RRC/LTE/MESSAGES/uper_encoder.c:85 > 5 0x5555576c5172 in do_NR_ULInformationTransfer /openair2/RRC/NR/MESSAGES/asn1_msg.c:965 > 6 0x555556fba691 in rrc_nrue /openair2/RRC/NR_UE/rrc_UE.c:1819 > 7 0x555556fc4d2e in rrc_nrue_task /openair2/RRC/NR_UE/rrc_UE.c:1717 > 8 0x7ffff5e94ac2 in start_thread nptl/pthread_create.c:442 --- openair2/RRC/NR_UE/rrc_UE.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 03440c0371..c8029df2d5 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1814,7 +1814,7 @@ void *rrc_nrue(void *notUsed) case NAS_UPLINK_DATA_REQ: { uint32_t length; - uint8_t *buffer; + uint8_t *buffer = NULL; NasUlDataReq *req = &NAS_UPLINK_DATA_REQ(msg_p); /* Create message for PDCP (ULInformationTransfer_t) */ length = do_NR_ULInformationTransfer(&buffer, req->nasMsg.length, req->nasMsg.data); @@ -1823,6 +1823,7 @@ void *rrc_nrue(void *notUsed) // error: the remote gNB is hardcoded here rb_id_t srb_id = rrc->Srb[2] == RB_ESTABLISHED ? 2 : 1; nr_pdcp_data_req_srb(rrc->ue_id, srb_id, 0, length, buffer, deliver_pdu_srb_rlc, NULL); + free(buffer); break; }