diff --git a/projects/clr/hipamd/src/hip_fatbin.cpp b/projects/clr/hipamd/src/hip_fatbin.cpp index 6611580bab..6de8713619 100644 --- a/projects/clr/hipamd/src/hip_fatbin.cpp +++ b/projects/clr/hipamd/src/hip_fatbin.cpp @@ -706,9 +706,13 @@ hipError_t FatBinaryInfo::AddDevProgram(hip::Device* device, const void* binary_ } hipError_t FatBinaryInfo::BuildProgram(const int device_id) { - // Device Id Check and Add DeviceProgram if not added so far + // Check for Device Id bounds and empty program to return gracefully DeviceIdCheck(device_id); + if (dev_programs_[device_id] == nullptr) { + return hipErrorInvalidKernelFile; + } + // If Program was already built skip this step and return success if (dev_programs_[device_id]->IsProgramBuilt(*g_devices[device_id]->devices()[0]) == false) { if (CL_SUCCESS !=