mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
virnwfilterbindingobj: Fix virNWFilterBindingObjNew()
The idea behind virNWFilterBindingObjNew() is to create and return an object of virNWFilterBindingObjClass class. The class is virObjectLockable (and the corresponding _virNWFilterBindingObj structure has virObjectLockable parent). But for some reason plain virObjectNew() is called. This is wrong because the mutex in the parent is left uninitialized. Next, the returned object is not locked. This is wrong because in some cases the returned object is added onto a list of bindings and then passed to virNWFilterBindingObjEndAPI() which unlocks it right away. This is potentially dangerous because we might just have unlocked the object for another thread. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5e0b2aeb29
commit
a7201789ab
@ -57,10 +57,15 @@ VIR_ONCE_GLOBAL_INIT(virNWFilterBindingObj);
|
|||||||
virNWFilterBindingObj *
|
virNWFilterBindingObj *
|
||||||
virNWFilterBindingObjNew(void)
|
virNWFilterBindingObjNew(void)
|
||||||
{
|
{
|
||||||
|
virNWFilterBindingObj *ret;
|
||||||
if (virNWFilterBindingObjInitialize() < 0)
|
if (virNWFilterBindingObjInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return virObjectNew(virNWFilterBindingObjClass);
|
if (!(ret = virObjectLockableNew(virNWFilterBindingObjClass)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
virObjectLock(ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user