[Mellanox] Fix the memory leak in mlnx-sfpd (#3128)
* fix the memory leak in on_pmpe. objects created via sx_api having convention new_<type_name> should be release explicitly via delete_<type_name>. * avoid duplicate code.
This commit is contained in:
parent
c3932e501b
commit
0c77acf2ea
@ -205,20 +205,18 @@ class MlnxSfpd:
|
||||
pkt = new_uint8_t_arr(pkt_size)
|
||||
recv_info_p = new_sx_receive_info_t_p()
|
||||
pmpe_t = sx_event_pmpe_t()
|
||||
logical_port_list = new_sx_port_log_id_t_arr(4)
|
||||
port_attributes_list = new_sx_port_attributes_t_arr(64)
|
||||
port_cnt_p = new_uint32_t_p()
|
||||
uint32_t_p_assign(port_cnt_p,64)
|
||||
label_port_list = []
|
||||
status = True
|
||||
module_state = 0
|
||||
|
||||
rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p)
|
||||
if rc != 0:
|
||||
log_error("sx_lib_host_ifc_recv exited with error, rc %d" % rc)
|
||||
status = False
|
||||
return status, label_port_list, module_state
|
||||
|
||||
else:
|
||||
status = True
|
||||
pmpe_t = recv_info_p.event_info.pmpe
|
||||
port_list_size = pmpe_t.list_size
|
||||
logical_port_list = pmpe_t.log_port_list
|
||||
@ -236,6 +234,12 @@ class MlnxSfpd:
|
||||
break
|
||||
label_port_list.append(lable_port)
|
||||
|
||||
delete_uint32_t_p(pkt_size_p)
|
||||
delete_uint8_t_arr(pkt)
|
||||
delete_sx_receive_info_t_p(recv_info_p)
|
||||
delete_sx_port_attributes_t_arr(port_attributes_list)
|
||||
delete_uint32_t_p(port_cnt_p)
|
||||
|
||||
return status, label_port_list, module_state,
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user