From 418b4d20060dc9b804e08e4ca86188d068347734 Mon Sep 17 00:00:00 2001 From: Kent Russell Date: Tue, 3 Sep 2024 08:30:09 -0400 Subject: [PATCH] kfdtest: Check for NULL at MCABackend creation The function can return NULL if it fails to create the backend, so check for NULL before using it. Change-Id: I4d6501bffd6dd0fc0d0f2224720f7d6dca1646f3 Signed-off-by: Kent Russell [ROCm/ROCR-Runtime commit: 545467be04bcee1f503c7edfd9fa912a5009b2c0] --- .../rocr-runtime/libhsakmt/tests/kfdtest/src/Assemble.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/Assemble.cpp b/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/Assemble.cpp index 53a321f956..9b799813a0 100644 --- a/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/Assemble.cpp +++ b/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/Assemble.cpp @@ -350,6 +350,11 @@ int Assembler::RunAssemble(const char* const AssemblySource) { #endif MCAsmBackend* MAB = TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions); + if (!MAB) { + outs() << "ASM Error: Unable to create MCA Backend\n"; + return -1; + } + std::unique_ptr Streamer(TheTarget->createMCObjectStreamer( TheTriple, Ctx, std::unique_ptr(MAB), MAB->createObjectWriter(*OS),