Index: openmp/libomptarget/plugins/amdgpu/impl/system.cpp =================================================================== --- openmp/libomptarget/plugins/amdgpu/impl/system.cpp +++ openmp/libomptarget/plugins/amdgpu/impl/system.cpp @@ -168,11 +168,13 @@ Elf *e = elf_memory(static_cast(binary), binSize); if (elf_kind(e) != ELF_K_ELF) { + elf_end(e); return failure; } size_t numpHdrs; if (elf_getphdrnum(e, &numpHdrs) != 0) { + elf_end(e); return failure; } @@ -191,11 +193,13 @@ address name = (address)¬e[1]; if (note->n_type == 7 || note->n_type == 8) { + elf_end(e); return failure; } else if (note->n_type == 10 /* NT_AMD_AMDGPU_HSA_METADATA */ && note->n_namesz == sizeof "AMD" && !memcmp(name, "AMD", note->n_namesz)) { // code object v2 uses yaml metadata, no longer supported + elf_end(e); return failure; } else if (note->n_type == 32 /* NT_AMDGPU_METADATA */ && note->n_namesz == sizeof "AMDGPU" && @@ -213,6 +217,7 @@ unsigned char *metadata_start = (unsigned char *)ptr + offset; unsigned char *metadata_end = metadata_start + core::alignUp(note->n_descsz, 4); + elf_end(e); return {metadata_start, metadata_end}; } ptr += sizeof(*note) + core::alignUp(note->n_namesz, sizeof(int)) + @@ -220,7 +225,7 @@ } } } - + elf_end(e); return failure; }