From 043bea8c2cddb78b5fabb72c382952730cdd1327 Mon Sep 17 00:00:00 2001 From: Sharmila Palani Date: Thu, 30 Mar 2023 13:14:08 -0700 Subject: [PATCH] Calling clean_up_ebpf_program --- libs/api/ebpf_api.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/api/ebpf_api.cpp b/libs/api/ebpf_api.cpp index cc66f3244f..8941d56a4b 100644 --- a/libs/api/ebpf_api.cpp +++ b/libs/api/ebpf_api.cpp @@ -1727,6 +1727,7 @@ _initialize_ebpf_object_from_native_file( program->handle = ebpf_handle_invalid; program->program_type = info->program_type; program->attach_type = info->expected_attach_type; + program->fd = ebpf_fd_invalid; program->section_name = ebpf_duplicate_string(info->section_name); if (program->section_name == nullptr) { @@ -1754,16 +1755,16 @@ _initialize_ebpf_object_from_native_file( Exit: if (result != EBPF_SUCCESS) { - if (program && object.programs.size() == 0) { - ebpf_free(program->section_name); - ebpf_free(program->program_name); + if (program) { + // Deallocate program, if it was allocated but not added to + // the object programs vector. + clean_up_ebpf_program(program); } clean_up_ebpf_programs(object.programs); clean_up_ebpf_maps(object.maps); } - ebpf_free(program); ebpf_free_sections(infos); EBPF_RETURN_RESULT(result); }