rocrtst: Various codeql fixes
Fix some potentially unreleased memory, null value checks, files not
closed, and other such issues reported by codeql
Change-Id: Ia679aff97a773a642d8c8cbadeae30955554a62e
Signed-off-by: Kent Russell <kent.russell@amd.com>
[ROCm/ROCR-Runtime commit: d64e33520f]
Этот коммит содержится в:
@@ -393,8 +393,8 @@ hsa_status_t LoadKernelFromObjFile(BinarySearch* bs) {
|
||||
}
|
||||
|
||||
err = hsa_code_object_reader_create_from_file(file_handle, &code_obj_rdr);
|
||||
RET_IF_HSA_ERR(err);
|
||||
close(file_handle);
|
||||
RET_IF_HSA_ERR(err);
|
||||
|
||||
err = hsa_executable_create_alt(HSA_PROFILE_FULL,
|
||||
HSA_DEFAULT_FLOAT_ROUNDING_MODE_DEFAULT, NULL, &executable);
|
||||
|
||||
@@ -177,8 +177,8 @@ void DeallocationNotifierTest::TestDeallocationNotifier(void) {
|
||||
// Attempt register on bad address (ie one not known to ROCr). Should fail.
|
||||
ptr = malloc(4096);
|
||||
status = hsa_amd_register_deallocation_callback(ptr, call, (void*)0xDEADBEEF);
|
||||
ASSERT_EQ(HSA_STATUS_ERROR_INVALID_ALLOCATION, status) << "Register deallocation callback error.";
|
||||
free(ptr);
|
||||
ASSERT_EQ(HSA_STATUS_ERROR_INVALID_ALLOCATION, status) << "Register deallocation callback error.";
|
||||
|
||||
// Allocate, register and free. Callback should complete before free returns.
|
||||
status = hsa_amd_memory_pool_allocate(pool, 4096, 0, &ptr);
|
||||
|
||||
@@ -404,6 +404,8 @@ void MemoryAccessTest::CPUAccessToGPUMemoryTest(hsa_agent_t cpuAgent,
|
||||
unsigned int *sys_data;
|
||||
sys_data = (unsigned int*)malloc(max_alloc_size);
|
||||
|
||||
ASSERT_NE(sys_data, nullptr);
|
||||
|
||||
for (unsigned int i = 0; i < max_element; ++i) {
|
||||
sys_data[i] = i;
|
||||
}
|
||||
|
||||
@@ -191,9 +191,17 @@ void SignalConcurrentTest::TestSignalCreateConcurrent(void) {
|
||||
hsa_status_t status;
|
||||
signals = reinterpret_cast<hsa_signal_t*>(malloc(sizeof(hsa_signal_t) * N * M));
|
||||
|
||||
ASSERT_NE(signals, nullptr);
|
||||
|
||||
struct rocrtst::test_group* tg_sg_create = rocrtst::TestGroupCreate(N);
|
||||
int* offset = reinterpret_cast<int*>(malloc(sizeof(int) * N));
|
||||
|
||||
EXPECT_NE(offset, nullptr);
|
||||
if (!offset) {
|
||||
free(signals);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < N; ++i) {
|
||||
offset[i] = i * M;
|
||||
rocrtst::TestGroupAdd(tg_sg_create, &TestSignalCreateFunction, offset + i, 1);
|
||||
@@ -269,9 +277,15 @@ void SignalConcurrentTest::TestSignalDestroyConcurrent(void) {
|
||||
|
||||
signals = reinterpret_cast<hsa_signal_t *>(malloc(sizeof(hsa_signal_t) * N * M));
|
||||
|
||||
ASSERT_NE(signals, nullptr);
|
||||
|
||||
struct rocrtst::test_group *tg_sg_destroy = rocrtst::TestGroupCreate(N);
|
||||
int *offset = reinterpret_cast<int *>(malloc(sizeof(int) * N));
|
||||
|
||||
EXPECT_NE(offset, nullptr);
|
||||
if (!offset)
|
||||
return;
|
||||
|
||||
for (i = 0; i < N; ++i) {
|
||||
int j;
|
||||
offset[i] = i * M;
|
||||
|
||||
@@ -467,6 +467,8 @@ void VirtMemoryTestBasic::CPUAccessToGPUMemoryTest(hsa_agent_t cpuAgent, hsa_age
|
||||
unsigned int* host_data = NULL;
|
||||
host_data = (unsigned int*)malloc(max_alloc_size);
|
||||
|
||||
ASSERT_NE(host_data, nullptr);
|
||||
|
||||
for (unsigned int i = 0; i < max_element; ++i) {
|
||||
host_data[i] = i;
|
||||
}
|
||||
@@ -477,6 +479,9 @@ void VirtMemoryTestBasic::CPUAccessToGPUMemoryTest(hsa_agent_t cpuAgent, hsa_age
|
||||
hsa_amd_vmem_alloc_handle_t mem_handle_host, mem_handle_dev;
|
||||
ASSERT_SUCCESS(
|
||||
hsa_amd_vmem_address_reserve(reinterpret_cast<void**>(&dev_data), max_alloc_size, 0, 0));
|
||||
|
||||
ASSERT_NE(dev_data, nullptr);
|
||||
|
||||
ASSERT_SUCCESS(hsa_amd_vmem_handle_create(device_pool, max_alloc_size, MEMORY_TYPE_NONE, 0,
|
||||
&mem_handle_dev));
|
||||
ASSERT_SUCCESS(
|
||||
|
||||
@@ -255,6 +255,8 @@ void DispatchTime::RunMulti() {
|
||||
uint64_t* index =
|
||||
reinterpret_cast<uint64_t*>(malloc(sizeof(uint64_t) * num_batch_));
|
||||
|
||||
ASSERT_NE(index, nullptr);
|
||||
|
||||
hsa_signal_store_screlease(aql().completion_signal, num_batch_);
|
||||
|
||||
for (uint32_t j = 0; j < num_batch_; j++) {
|
||||
|
||||
@@ -262,6 +262,8 @@ void EnqueueLatency::EnqueueMultiPackets() {
|
||||
uint64_t* index =
|
||||
reinterpret_cast<uint64_t*>(malloc(sizeof(uint64_t) * num_of_pkts_));
|
||||
|
||||
ASSERT_NE(index, nullptr);
|
||||
|
||||
hsa_signal_store_screlease(aql().completion_signal, num_of_pkts_);
|
||||
|
||||
for (uint32_t j = 0; j < num_of_pkts_; j++) {
|
||||
|
||||
Ссылка в новой задаче
Block a user