|
23 | 23 | #include "asan_stack.h" |
24 | 24 | #include "asan_suppressions.h" |
25 | 25 | #include "asan_thread.h" |
| 26 | +#include "hsa.h" |
26 | 27 | #include "lsan/lsan_common.h" |
27 | 28 | #include "sanitizer_common/sanitizer_allocator_checks.h" |
28 | 29 | #include "sanitizer_common/sanitizer_allocator_interface.h" |
@@ -1554,18 +1555,21 @@ hsa_status_t asan_hsa_amd_pointer_info(const void* ptr, |
1554 | 1555 | uint32_t* num_agents_accessible, |
1555 | 1556 | hsa_agent_t** accessible) { |
1556 | 1557 | void* ptr_ = get_allocator().GetBlockBegin(ptr); |
1557 | | - AsanChunk* m = instance.GetAsanChunkByAddr(reinterpret_cast<uptr>(ptr_)); |
1558 | | - hsa_status_t status; |
1559 | | - if (ptr_ && m) |
| 1558 | + AsanChunk* m = ptr_ |
| 1559 | + ? instance.GetAsanChunkByAddr(reinterpret_cast<uptr>(ptr_)) |
| 1560 | + : nullptr; |
| 1561 | + hsa_status_t status = HSA_STATUS_ERROR_NOT_INITIALIZED; |
| 1562 | + if (ptr_ && m) { |
1560 | 1563 | status = REAL(hsa_amd_pointer_info)(ptr, info, alloc, num_agents_accessible, |
1561 | 1564 | accessible); |
1562 | | - if (status == HSA_STATUS_SUCCESS && info && ptr_ && m) { |
1563 | | - static_assert(AP_.kMetadataSize == 0, "Expression below requires this"); |
1564 | | - info->agentBaseAddress = reinterpret_cast<void*>( |
1565 | | - reinterpret_cast<uptr>(info->agentBaseAddress) + kPageSize_); |
1566 | | - info->hostBaseAddress = reinterpret_cast<void*>( |
1567 | | - reinterpret_cast<uptr>(info->hostBaseAddress) + kPageSize_); |
1568 | | - info->sizeInBytes = m->UsedSize(); |
| 1565 | + if (status == HSA_STATUS_SUCCESS && info) { |
| 1566 | + static_assert(AP_.kMetadataSize == 0, "Expression below requires this"); |
| 1567 | + info->agentBaseAddress = reinterpret_cast<void*>( |
| 1568 | + reinterpret_cast<uptr>(info->agentBaseAddress) + kPageSize_); |
| 1569 | + info->hostBaseAddress = reinterpret_cast<void*>( |
| 1570 | + reinterpret_cast<uptr>(info->hostBaseAddress) + kPageSize_); |
| 1571 | + info->sizeInBytes = m->UsedSize(); |
| 1572 | + } |
1569 | 1573 | } |
1570 | 1574 | return status; |
1571 | 1575 | } |
|
0 commit comments