netlink_init.c: Memory leak
Found by `-fsanitize=address`.
This commit is contained in:
@@ -133,6 +133,7 @@ int netlink_init_mbms_tun(char *ifprefix, int id) {//for UE, id = 1, 2, ...,
|
|||||||
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
|
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
|
||||||
nas_dest_addr.nl_groups = 0; /* unicast */
|
nas_dest_addr.nl_groups = 0; /* unicast */
|
||||||
// TX PART
|
// TX PART
|
||||||
|
free(nas_nlh_tx);
|
||||||
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
|
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
|
||||||
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
|
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
|
||||||
/* Fill the netlink message header */
|
/* Fill the netlink message header */
|
||||||
@@ -193,6 +194,7 @@ int netlink_init_tun(char *ifprefix, int num_if, int id) {//for UE, id = 1, 2, .
|
|||||||
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
|
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
|
||||||
nas_dest_addr.nl_groups = 0; /* unicast */
|
nas_dest_addr.nl_groups = 0; /* unicast */
|
||||||
// TX PART
|
// TX PART
|
||||||
|
free(nas_nlh_tx);
|
||||||
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
|
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
|
||||||
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
|
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
|
||||||
/* Fill the netlink message header */
|
/* Fill the netlink message header */
|
||||||
@@ -251,6 +253,7 @@ int netlink_init(void) {
|
|||||||
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
|
nas_dest_addr.nl_pid = 0; /* For Linux Kernel */
|
||||||
nas_dest_addr.nl_groups = 0; /* unicast */
|
nas_dest_addr.nl_groups = 0; /* unicast */
|
||||||
// TX PART
|
// TX PART
|
||||||
|
free(nas_nlh_tx);
|
||||||
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
|
nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD));
|
||||||
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
|
memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD));
|
||||||
/* Fill the netlink message header */
|
/* Fill the netlink message header */
|
||||||
@@ -273,3 +276,8 @@ int netlink_init(void) {
|
|||||||
return(nas_sock_fd[0]);
|
return(nas_sock_fd[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void netlink_cleanup(void)
|
||||||
|
{
|
||||||
|
free(nas_nlh_tx);
|
||||||
|
nas_nlh_tx = NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,5 +64,6 @@ void clear_UE_transport_info(uint8_t);
|
|||||||
int netlink_init(void);
|
int netlink_init(void);
|
||||||
int netlink_init_tun(char *ifsuffix, int num_if, int id);
|
int netlink_init_tun(char *ifsuffix, int num_if, int id);
|
||||||
int netlink_init_mbms_tun(char *ifsuffix, int id);
|
int netlink_init_mbms_tun(char *ifsuffix, int id);
|
||||||
|
void netlink_cleanup(void);
|
||||||
|
|
||||||
#endif /* EMU_PROTO_H_ */
|
#endif /* EMU_PROTO_H_ */
|
||||||
|
|||||||
@@ -2331,6 +2331,7 @@ pdcp_free (
|
|||||||
void pdcp_module_cleanup (void)
|
void pdcp_module_cleanup (void)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
|
netlink_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -803,6 +803,7 @@ int main ( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdcp_module_cleanup();
|
||||||
terminate_opt();
|
terminate_opt();
|
||||||
logClean();
|
logClean();
|
||||||
printf("Bye.\n");
|
printf("Bye.\n");
|
||||||
|
|||||||
@@ -834,6 +834,7 @@ int main( int argc, char **argv ) {
|
|||||||
if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func)
|
if (PHY_vars_UE_g[0][0]->rfdevice.trx_end_func)
|
||||||
PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice);
|
PHY_vars_UE_g[0][0]->rfdevice.trx_end_func(&PHY_vars_UE_g[0][0]->rfdevice);
|
||||||
|
|
||||||
|
pdcp_module_cleanup();
|
||||||
terminate_opt();
|
terminate_opt();
|
||||||
logClean();
|
logClean();
|
||||||
printf("Bye.\n");
|
printf("Bye.\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user