SWDEV-497288 - Fix Segfault when kernel param is nullptr

1) for case where kernelParam_.func = nullptr, the validation
fails in setParam call and memory is not alloced for kernelParams
2) destructor path segfaults trying to free the kernelParams memory.
3) copy of params is done after function validation is successful.

Change-Id: I6338e0c89f259632e4115f0508e2f240bc207fd9
This commit is contained in:
Rahul Manocha
2024-11-21 17:13:25 -08:00
committed by Rahul Manocha
parent e0c11624e5
commit 1ac9286b5a
+3 -1
View File
@@ -1129,6 +1129,9 @@ class GraphKernelNode : public GraphNode {
const amd::KernelSignature& signature = kernel->signature();
numParams_ = signature.numParameters();
// Copy gridDim, blockDim, sharedMemBytes and func
kernelParams_ = *pNodeParams;
// Allocate/assign memory if params are passed part of 'kernelParams'
if (pNodeParams->kernelParams != nullptr) {
kernelParams_.kernelParams = (void**)malloc(numParams_ * sizeof(void*));
@@ -1303,7 +1306,6 @@ class GraphKernelNode : public GraphNode {
return status;
}
freeParams();
kernelParams_ = *params;
status = copyParams(params);
if (status != hipSuccess) {
ClPrint(amd::LOG_ERROR, amd::LOG_CODE, "[hipGraph] Failed to set params");