From 682173c8511932d5ba0dac67c94ccdaf6b93e7f3 Mon Sep 17 00:00:00 2001 From: Xiaogang Chen Date: Wed, 24 May 2023 18:16:56 -0500 Subject: [PATCH] libhsakmt: allow gpu nodeid arrary is null and number of gpu is zero. Allow hsaKmtRegisterGraphicsHandleToNodes parameters NodeArray be null and NumberOfNodes be zero at same time. It is the case we want the imported buffer not be registered by kfd. Set gpu_id_array = NULL explicitly to avoid free uninitialized gpuid array. Report: Yat Sin, David Signed-off-by: Xiaogang Chen Change-Id: I3babc1160c9573e38dd11d81965c8de2b70cae2e [ROCm/ROCR-Runtime commit: f6183f937e8c7095192ae61b443ff46a15a7f30d] --- projects/rocr-runtime/src/memory.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/rocr-runtime/src/memory.c b/projects/rocr-runtime/src/memory.c index d6e89ec565..6b3eaf496b 100644 --- a/projects/rocr-runtime/src/memory.c +++ b/projects/rocr-runtime/src/memory.c @@ -306,13 +306,15 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtRegisterGraphicsHandleToNodes(HSAuint64 GraphicsRe HSAuint32 *NodeArray) { CHECK_KFD_OPEN(); - uint32_t *gpu_id_array; + uint32_t *gpu_id_array = NULL; HSAKMT_STATUS ret = HSAKMT_STATUS_SUCCESS; pr_debug("[%s] number of nodes %lu\n", __func__, NumberOfNodes); - ret = validate_nodeid_array(&gpu_id_array, - NumberOfNodes, NodeArray); + if (NodeArray != NULL || NumberOfNodes != 0) { + ret = validate_nodeid_array(&gpu_id_array, + NumberOfNodes, NodeArray); + } if (ret == HSAKMT_STATUS_SUCCESS) { ret = fmm_register_graphics_handle(