From d00b2a0953bb2a90fafaf3f8c6705b4021f04e08 Mon Sep 17 00:00:00 2001 From: "Brzak, Branislav" Date: Wed, 16 Apr 2025 11:00:54 +0200 Subject: [PATCH] SWDEV-525423 - In COMGR Loader don't open file if image is already mapped (#193) --- hipamd/src/hip_fatbin.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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.