diff --git a/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc b/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc index 0da0c36345..4a07ce9515 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp16/arithmetic_fp16.cc @@ -107,7 +107,16 @@ int ArithmeticFP16CPUKernel::PreProcess() { MS_LOG(ERROR) << "InferShape fail!"; return ret; } - param_ = reinterpret_cast(PopulateArithmetic(primitive_)); + if (op_parameter_ != nullptr) { + free(op_parameter_); + op_parameter_ = nullptr; + } + op_parameter_ = PopulateArithmetic(primitive_); + if (op_parameter_ == nullptr) { + MS_LOG(ERROR) << "Malloc parameter failed"; + return RET_ERROR; + } + param_ = reinterpret_cast(op_parameter_); ret = ReSize(); if (ret != 0) { MS_LOG(ERROR) << "ReSize fail!ret: " << ret; diff --git a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.cc b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.cc index 01e32d1c35..412a40e6d6 100644 --- a/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.cc +++ b/mindspore/lite/src/runtime/kernel/arm/fp32/arithmetic.cc @@ -48,7 +48,16 @@ int ArithmeticCPUKernel::PreProcess() { MS_LOG(ERROR) << "InferShape fail!"; return ret; } - arithmeticParameter_ = reinterpret_cast(PopulateArithmetic(primitive_)); + if (op_parameter_ != nullptr) { + free(op_parameter_); + op_parameter_ = nullptr; + } + op_parameter_ = PopulateArithmetic(primitive_); + if (op_parameter_ == nullptr) { + MS_LOG(ERROR) << "Malloc parameter failed"; + return RET_ERROR; + } + arithmeticParameter_ = reinterpret_cast(op_parameter_); ret = ReSize(); if (ret != 0) { MS_LOG(ERROR) << "ReSize fail!ret: " << ret;