提交 cc743e23 编写于 作者: D Daniel P. Berrange

Add missing checks for NULL in domain lock manager

The domain lock manager forgot to include a bunch of checks
for NULL which could occur on OOM

* src/locking/domain_lock.c: Add checks for NULL
上级 a8182206
......@@ -157,10 +157,13 @@ int virDomainLockProcessStart(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
bool paused)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
virLockManagerPtr lock;
int ret;
int flags = VIR_LOCK_MANAGER_ACQUIRE_RESTRICT;
if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
return -1;
if (paused)
flags |= VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY;
......@@ -175,9 +178,13 @@ int virDomainLockProcessPause(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
char **state)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
int ret = virLockManagerRelease(lock, state, 0);
virLockManagerPtr lock;
int ret;
if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
return -1;
ret = virLockManagerRelease(lock, state, 0);
virLockManagerFree(lock);
return ret;
......@@ -187,9 +194,13 @@ int virDomainLockProcessResume(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
const char *state)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
int ret = virLockManagerAcquire(lock, state, 0);
virLockManagerPtr lock;
int ret;
if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
return -1;
ret = virLockManagerAcquire(lock, state, 0);
virLockManagerFree(lock);
return ret;
......@@ -199,9 +210,13 @@ int virDomainLockProcessInquire(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
char **state)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, true);
int ret = virLockManagerInquire(lock, state, 0);
virLockManagerPtr lock;
int ret;
if (!(lock = virDomainLockManagerNew(plugin, dom, true)))
return -1;
ret = virLockManagerInquire(lock, state, 0);
virLockManagerFree(lock);
return ret;
......@@ -212,9 +227,12 @@ int virDomainLockDiskAttach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainDiskDefPtr disk)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
virLockManagerPtr lock;
int ret = -1;
if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
return -1;
if (virDomainLockManagerAddDisk(lock, disk) < 0)
goto cleanup;
......@@ -233,9 +251,12 @@ int virDomainLockDiskDetach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainDiskDefPtr disk)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
virLockManagerPtr lock;
int ret = -1;
if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
return -1;
if (virDomainLockManagerAddDisk(lock, disk) < 0)
goto cleanup;
......@@ -255,9 +276,12 @@ int virDomainLockLeaseAttach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainLeaseDefPtr lease)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
virLockManagerPtr lock;
int ret = -1;
if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
return -1;
if (virDomainLockManagerAddLease(lock, lease) < 0)
goto cleanup;
......@@ -276,9 +300,12 @@ int virDomainLockLeaseDetach(virLockManagerPluginPtr plugin,
virDomainObjPtr dom,
virDomainLeaseDefPtr lease)
{
virLockManagerPtr lock = virDomainLockManagerNew(plugin, dom, false);
virLockManagerPtr lock;
int ret = -1;
if (!(lock = virDomainLockManagerNew(plugin, dom, false)))
return -1;
if (virDomainLockManagerAddLease(lock, lease) < 0)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册