SWDEV-298982 - hipMemPrefetchAsync should not allow more bytes than the actual size allocated

Change-Id: If8df97a79a16d39c66c508a8927ae1b4c276663e
This commit is contained in:
Satyanvesh Dittakavi
2021-08-16 02:51:17 -04:00
parent a41c5c783b
commit a984cbf90c
+8
View File
@@ -79,6 +79,14 @@ hipError_t hipMemPrefetchAsync(const void* dev_ptr, size_t count, int device,
if ((dev_ptr == nullptr) || (count == 0)) {
HIP_RETURN(hipErrorInvalidValue);
}
size_t offset = 0;
amd::Memory* memObj = getMemoryObject(dev_ptr, offset);
// Return error if count passed is more than the actual size allocated
if (memObj && count > (memObj->getSize() - offset)) {
return hipErrorInvalidValue;
}
amd::HostQueue* queue = nullptr;
bool cpu_access = (device == hipCpuDeviceId) ? true : false;