Commit 28e31028 authored by Rúben Soares Silva's avatar Rúben Soares Silva Committed by Robert Schmidt

Address memory leaks found in P7 messages handling

Add nr_fapi_p7 library to NFAPI_USER_LIB for access to utility functions

Change message handlers to use the utility functions to  copy and properly free the messages

Change the SRS handler to call the handler for the measurements instead of trying to copy to RC.gNB[0], which does not exist

Change nfapi_nr_p7_message_unpack to not allocate unneeded memory
parent e8fe6cef
......@@ -759,6 +759,7 @@ set(NFAPI_USER_SRC
)
add_library(NFAPI_USER_LIB ${NFAPI_USER_SRC})
target_link_libraries(NFAPI_USER_LIB PRIVATE asn1_lte_rrc_hdrs asn1_nr_rrc_hdrs)
target_link_libraries(NFAPI_USER_LIB PRIVATE nr_fapi_p7)
include_directories(${NFAPI_USER_DIR})
# Layer 1
......
This diff is collapsed.
......@@ -6278,43 +6278,33 @@ int nfapi_nr_p7_message_unpack(void *pMessageBuf,
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION, unpackedBufLen)) {
nfapi_nr_rx_data_indication_t *msg = (nfapi_nr_rx_data_indication_t *)pMessageHeader;
msg->pdu_list = (nfapi_nr_rx_data_pdu_t *)malloc(sizeof(nfapi_nr_rx_data_pdu_t));
msg->pdu_list->pdu = (uint8_t *)malloc(sizeof(uint8_t));
result = unpack_nr_rx_data_indication(&pReadPackedMessage, end, msg, config);
result = unpack_nr_rx_data_indication(&pReadPackedMessage, end, pMessageHeader, config);
}
break;
break;
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION, unpackedBufLen)) {
nfapi_nr_crc_indication_t *msg = (nfapi_nr_crc_indication_t *)pMessageHeader;
msg->crc_list = (nfapi_nr_crc_t *)malloc(sizeof(nfapi_nr_crc_t));
result = unpack_nr_crc_indication(&pReadPackedMessage, end, msg, config);
}
break;
result = unpack_nr_crc_indication(&pReadPackedMessage, end, pMessageHeader, config);
}
break;
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION, unpackedBufLen)) {
nfapi_nr_uci_indication_t *msg = (nfapi_nr_uci_indication_t *)pMessageHeader;
msg->uci_list = (nfapi_nr_uci_t *)malloc(sizeof(nfapi_nr_uci_t));
result = unpack_nr_uci_indication(&pReadPackedMessage, end, msg, config);
}
break;
result = unpack_nr_uci_indication(&pReadPackedMessage, end, pMessageHeader, config);
}
break;
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION, unpackedBufLen)) {
nfapi_nr_srs_indication_t *msg = (nfapi_nr_srs_indication_t *)pMessageHeader;
msg->pdu_list = (nfapi_nr_srs_indication_pdu_t *)malloc(sizeof(nfapi_nr_srs_indication_pdu_t));
result = unpack_nr_srs_indication(&pReadPackedMessage, end, msg, config);
}
break;
result = unpack_nr_srs_indication(&pReadPackedMessage, end, pMessageHeader, config);
}
break;
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION, unpackedBufLen)) {
nfapi_nr_rach_indication_t *msg = (nfapi_nr_rach_indication_t *)pMessageHeader;
result = unpack_nr_rach_indication(&pReadPackedMessage, end, msg, config);
}
break;
result = unpack_nr_rach_indication(&pReadPackedMessage, end, pMessageHeader, config);
}
break;
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
if (check_nr_fapi_unpack_length(NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC, unpackedBufLen))
......
......@@ -29,6 +29,7 @@
#include "nfapi/oai_integration/aerial/fapi_nvIPC.h"
#endif
#include "vnf_p7.h"
#include "nr_fapi_p7_utils.h"
#ifdef NDEBUG
# warning assert is disabled
......@@ -1511,6 +1512,7 @@ void vnf_handle_nr_slot_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
{
(vnf_p7->_public.nr_slot_indication)(&ind);
}
free_slot_indication(&ind);
}
}
......@@ -1537,6 +1539,7 @@ void vnf_handle_nr_rx_data_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t*
{
(vnf_p7->_public.nr_rx_data_indication)(&ind);
}
free_rx_data_indication(&ind);
}
}
}
......@@ -1563,6 +1566,7 @@ void vnf_handle_nr_crc_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
{
(vnf_p7->_public.nr_crc_indication)(&ind);
}
free_crc_indication(&ind);
}
}
}
......@@ -1588,6 +1592,7 @@ void vnf_handle_nr_srs_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
{
(vnf_p7->_public.nr_srs_indication)(&ind);
}
free_srs_indication(&ind);
}
}
}
......@@ -1614,6 +1619,7 @@ void vnf_handle_nr_uci_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_
{
(vnf_p7->_public.nr_uci_indication)(&ind);
}
free_uci_indication(&ind);
}
}
}
......@@ -1640,6 +1646,7 @@ void vnf_handle_nr_rach_indication(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf
{
(vnf_p7->_public.nr_rach_indication)(&ind);
}
free_rach_indication(&ind);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment