Skip to content

Commit

Permalink
Calling clean_up_ebpf_program
Browse files Browse the repository at this point in the history
  • Loading branch information
shpalani committed Mar 30, 2023
1 parent fc8d952 commit 043bea8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libs/api/ebpf_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 043bea8

Please sign in to comment.