diff --git a/hipamd/src/hip_fatbin.cpp b/hipamd/src/hip_fatbin.cpp index 4f374d11e8..09d1393b01 100644 --- a/hipamd/src/hip_fatbin.cpp +++ b/hipamd/src/hip_fatbin.cpp @@ -206,7 +206,7 @@ hipError_t FatBinaryInfo::ExtractFatBinaryUsingCOMGR(const std::vector 0) { + if (image_ == nullptr && fname_.size() > 0) { // Get File Handle & size of the file. ufd_ = PlatformState::instance().GetUniqueFileHandle(fname_.c_str()); if (ufd_ == nullptr) { @@ -219,14 +219,13 @@ hipError_t FatBinaryInfo::ExtractFatBinaryUsingCOMGR(const std::vectorfdesc_, ufd_->fsize_, foffset_, &image_)) { - LogError("Cannot map the file descriptor"); - PlatformState::instance().CloseUniqueFileHandle(ufd_); - return hipErrorInvalidValue; - } - image_mapped_ = true; + if (!amd::Os::MemoryMapFileDesc(ufd_->fdesc_, ufd_->fsize_, foffset_, &image_)) { + LogError("Cannot map the file descriptor"); + PlatformState::instance().CloseUniqueFileHandle(ufd_); + return hipErrorInvalidValue; } + + image_mapped_ = true; } // At this line, image should be a valid ptr.