SWDEV-222615 - delete VirtualGPU::Queue and return NULL when Pal::IDevice::CreateQueue() fails, in order to avoid undefined behavior and crash.

Change-Id: I4b94d3b3b0495530a8bf7840dc77a98aed9aa8ae
This commit is contained in:
Todd tiantuo Li
2020-03-16 16:41:10 -07:00
parent b0164a9819
commit b96e25c5f8
+4 -1
View File
@@ -149,6 +149,9 @@ VirtualGPU::Queue* VirtualGPU::Queue::Create(const VirtualGPU& gpu, Pal::QueueTy
info->engineType_ = qCreateInfo.engineType;
// Save uniqueue index for scratch buffer access
info->index_ = index;
} else {
delete queue;
return nullptr;
}
} else {
int usage = std::numeric_limits<int>::max();
@@ -157,7 +160,7 @@ VirtualGPU::Queue* VirtualGPU::Queue::Create(const VirtualGPU& gpu, Pal::QueueTy
for (const auto& it : gpu.dev().QueuePool()) {
if ((qCreateInfo.engineType == it.second->engineType_) &&
(it.second->counter_ <= usage)) {
if ((it.second->counter_ < usage) ||
if ((it.second->counter_ < usage) ||
// Preserve the order of allocations, because SDMA engines
// should be used in round-robin manner
((it.second->counter_ == usage) && (it.second->index_ < indexBase))) {