summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-util/hip')
-rw-r--r--dev-util/hip/files/hip-5.7.1-fix-mmap-oom-check.patch41
-rw-r--r--dev-util/hip/hip-5.7.1-r2.ebuild1
2 files changed, 42 insertions, 0 deletions
diff --git a/dev-util/hip/files/hip-5.7.1-fix-mmap-oom-check.patch b/dev-util/hip/files/hip-5.7.1-fix-mmap-oom-check.patch
new file mode 100644
index 000000000000..dbafe4e11a74
--- /dev/null
+++ b/dev-util/hip/files/hip-5.7.1-fix-mmap-oom-check.patch
@@ -0,0 +1,41 @@
+Backport of SWDEV-417691 - Error handling for MemoryMap OS calls.
+The issue was fixed in rocclr 6.0.0.
+https://github.com/ROCm/clr/commit/7a10423a44b8b353f67539dc1ae14c0b99c209b8
+--- a/rocclr/os/os_posix.cpp
++++ b/rocclr/os/os_posix.cpp
+@@ -214,7 +214,7 @@ address Os::reserveMemory(address start, size_t size, size_t alignment, MemProt
+ MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS, 0, 0);
+
+ // check for out of memory
+- if (mem == NULL) return NULL;
++ if (mem == MAP_FAILED) return NULL;
+
+ address aligned = alignUp(mem, alignment);
+
+@@ -842,7 +842,7 @@ bool Os::MemoryMapFileDesc(FileDesc fdesc, size_t fsize, size_t foffset, const v
+ }
+
+ *mmap_ptr = mmap(NULL, fsize, PROT_READ, MAP_SHARED, fdesc, foffset);
+- return true;
++ return (*mmap_ptr == MAP_FAILED) ? false : true;
+ }
+
+ bool Os::MemoryUnmapFile(const void* mmap_ptr, size_t mmap_size) {
+@@ -874,7 +874,7 @@ bool Os::MemoryMapFile(const char* fname, const void** mmap_ptr, size_t* mmap_si
+
+ close(fd);
+
+- if (*mmap_ptr == nullptr) {
++ if (*mmap_ptr == MAP_FAILED) {
+ return false;
+ }
+
+@@ -899,7 +899,7 @@ bool Os::MemoryMapFileTruncated(const char* fname, const void** mmap_ptr, size_t
+
+ close(fd);
+
+- if (*mmap_ptr == nullptr) {
++ if (*mmap_ptr == MAP_FAILED) {
+ return false;
+ }
+ \ No newline at end of file
diff --git a/dev-util/hip/hip-5.7.1-r2.ebuild b/dev-util/hip/hip-5.7.1-r2.ebuild
index f91ef2a7083c..034378272f53 100644
--- a/dev-util/hip/hip-5.7.1-r2.ebuild
+++ b/dev-util/hip/hip-5.7.1-r2.ebuild
@@ -47,6 +47,7 @@ PATCHES=(
"${FILESDIR}/${PN}-5.7.1-disable-stack-protector.patch"
"${FILESDIR}/${PN}-5.7.1-no_asan_doc.patch"
"${FILESDIR}/${PN}-5.7.1-extend-isa-compatibility-check.patch"
+ "${FILESDIR}/${PN}-5.7.1-fix-mmap-oom-check.patch"
)
S="${WORKDIR}/clr-rocm-${PV}/"