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
This commit is contained in:
Daniel P. Berrange 2011-06-14 09:05:54 +01:00
parent a81822063d
commit cc743e2314

View File

@ -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;