提交 ae83e02f 编写于 作者: J John Ferlan

esx_driver: Resolve Coverity RESOURCE_LEAK on error paths

New Coverity release found a couple of error paths where memory would be
leaked in an error/goto path before being properly handled.
上级 7f953b19
......@@ -3393,7 +3393,6 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
esxVI_AutoStartPowerInfo *powerInfoList = NULL;
esxVI_AutoStartPowerInfo *powerInfo = NULL;
esxVI_AutoStartPowerInfo *newPowerInfo = NULL;
bool newPowerInfo_isAppended = false;
if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
......@@ -3468,7 +3467,7 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
goto cleanup;
}
newPowerInfo_isAppended = true;
newPowerInfo = NULL;
if (esxVI_ReconfigureAutostart
(priv->primary,
......@@ -3491,9 +3490,7 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
esxVI_AutoStartDefaults_Free(&defaults);
esxVI_AutoStartPowerInfo_Free(&powerInfoList);
if (!newPowerInfo_isAppended) {
esxVI_AutoStartPowerInfo_Free(&newPowerInfo);
}
return result;
}
......@@ -3640,6 +3637,7 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Shares level has unknown value %d"),
(int)sharesInfo->level);
esxVI_SharesInfo_Free(&sharesInfo);
goto cleanup;
}
......@@ -3743,6 +3741,7 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
}
spec->cpuAllocation->shares = sharesInfo;
sharesInfo = NULL;
if (params[i].value.i >= 0) {
spec->cpuAllocation->shares->level = esxVI_SharesLevel_Custom;
......@@ -3796,6 +3795,7 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain,
result = 0;
cleanup:
esxVI_SharesInfo_Free(&sharesInfo);
esxVI_ObjectContent_Free(&virtualMachine);
esxVI_VirtualMachineConfigSpec_Free(&spec);
esxVI_ManagedObjectReference_Free(&task);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册