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


[ROCm/clr commit: 1ac9286b5a]
Этот коммит содержится в:
Rahul Manocha authored and Rahul Manocha committed 2024-11-26 11:34:41 -05:00
1 родитель d6a34b0f9f
Коммит 234f7bd197
1 file changed
+3 -1
+3 -1
Просмотреть файл
@@ -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");