forked from acouzens/open5gs
fix the memory leak
This commit is contained in:
parent
773d31a17e
commit
4d4621d9a4
|
@ -416,6 +416,10 @@ pgw_bearer_t *pgw_sess_add(c_uint8_t id)
|
|||
d_assert(bearer, pgw_sess_remove(sess); return NULL,
|
||||
"Can't add default bearer context");
|
||||
|
||||
sess->ip_pool = pgw_ip_pool_alloc();
|
||||
d_assert(sess->ip_pool, pgw_sess_remove(sess); return NULL,
|
||||
"Can't alloc IP pool");
|
||||
|
||||
return bearer;
|
||||
}
|
||||
|
||||
|
@ -423,6 +427,8 @@ status_t pgw_sess_remove(pgw_sess_t *sess)
|
|||
{
|
||||
d_assert(sess, return CORE_ERROR, "Null param");
|
||||
|
||||
pgw_ip_pool_free(sess->ip_pool);
|
||||
|
||||
pgw_pdn_remove_all(sess);
|
||||
pgw_bearer_remove_all(sess);
|
||||
|
||||
|
|
|
@ -49,6 +49,12 @@ typedef struct _pgw_context_t {
|
|||
list_t ip_pool_list;
|
||||
} pgw_context_t;
|
||||
|
||||
typedef struct _pgw_ip_pool_t {
|
||||
lnode_t node; /**< A node of list_t */
|
||||
|
||||
c_uint32_t ue_addr;
|
||||
} pgw_ip_pool_t;
|
||||
|
||||
typedef struct _pgw_sess_t {
|
||||
lnode_t node; /**< A node of list_t */
|
||||
index_t index; /**< An index of this node */
|
||||
|
@ -63,6 +69,7 @@ typedef struct _pgw_sess_t {
|
|||
|
||||
list_t pdn_list;
|
||||
list_t bearer_list;
|
||||
pgw_ip_pool_t *ip_pool;
|
||||
} pgw_sess_t;
|
||||
|
||||
typedef struct _pgw_bearer_t {
|
||||
|
@ -82,12 +89,6 @@ typedef struct _pgw_bearer_t {
|
|||
pgw_sess_t *sess;
|
||||
} pgw_bearer_t;
|
||||
|
||||
typedef struct _pgw_ip_pool_t {
|
||||
lnode_t node; /**< A node of list_t */
|
||||
|
||||
c_uint32_t ue_addr;
|
||||
} pgw_ip_pool_t;
|
||||
|
||||
CORE_DECLARE(status_t) pgw_context_init(void);
|
||||
CORE_DECLARE(status_t) pgw_context_parse_config(void);
|
||||
CORE_DECLARE(status_t) pgw_context_final(void);
|
||||
|
|
|
@ -151,6 +151,8 @@ void pgw_handle_create_session_request(
|
|||
d_assert(bearer, return, "No Bearer Context");
|
||||
sess = bearer->sess;
|
||||
d_assert(sess, return, "Null param");
|
||||
ip_pool = sess->ip_pool;
|
||||
d_assert(ip_pool, return, "Null param");
|
||||
|
||||
memcpy(apn, req->access_point_name.data, req->access_point_name.len);
|
||||
apn[req->access_point_name.len] = 0;
|
||||
|
@ -195,11 +197,6 @@ void pgw_handle_create_session_request(
|
|||
rsp->pgw_s5_s8__s2a_s2b_f_teid_for_pmip_based_interface_or_for_gtp_based_control_plane_interface.
|
||||
len = GTP_F_TEID_IPV4_LEN;
|
||||
|
||||
ip_pool = pgw_ip_pool_alloc();
|
||||
d_assert(ip_pool,
|
||||
pgw_sess_remove(sess); pgw_pdn_remove(pdn); return,
|
||||
"No PDN Context");
|
||||
|
||||
pdn->paa.pdn_type = GTP_PDN_TYPE_IPV4;
|
||||
pdn->paa.ipv4_addr = ip_pool->ue_addr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue