Prevent writing to null ptr if malloc fails on cpuAddrBo

Change-Id: Ie83224c993fa3fc308551f009dadddca29549057
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
This commit is contained in:
Dongwon Kim 2020-05-12 11:37:26 -07:00 committed by sys_ocldev
parent bc94d79c2e
commit 7157b41856
1 changed files with 1 additions and 0 deletions

View File

@ -49,6 +49,7 @@ DrmMemoryManager::DrmMemoryManager(gemCloseWorkerMode mode,
BufferObject *bo = nullptr;
if (forcePinEnabled || validateHostPtrMemory) {
auto cpuAddrBo = alignedMallocWrapper(MemoryConstants::pageSize, MemoryConstants::pageSize);
UNRECOVERABLE_IF(cpuAddrBo == nullptr);
// Preprogram the Bo with MI_BATCH_BUFFER_END and MI_NOOP. This BO will be used as the last BB in a series to indicate the end of submission.
reinterpret_cast<uint32_t *>(cpuAddrBo)[0] = 0x05000000; // MI_BATCH_BUFFER_END
reinterpret_cast<uint32_t *>(cpuAddrBo)[1] = 0; // MI_NOOP