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