mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
virSecurityManagerNewDriver: Fix code pattern
Use 'error' label to free allocated memory. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
39015a6f3a
commit
c060e400d9
@ -73,8 +73,8 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv,
|
||||
const char *virtDriver,
|
||||
unsigned int flags)
|
||||
{
|
||||
virSecurityManagerPtr mgr;
|
||||
char *privateData;
|
||||
virSecurityManagerPtr mgr = NULL;
|
||||
char *privateData = NULL;
|
||||
|
||||
if (virSecurityManagerInitialize() < 0)
|
||||
return NULL;
|
||||
@ -87,22 +87,22 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv,
|
||||
if (VIR_ALLOC_N(privateData, drv->privateDataLen) < 0)
|
||||
return NULL;
|
||||
|
||||
if (!(mgr = virObjectLockableNew(virSecurityManagerClass))) {
|
||||
VIR_FREE(privateData);
|
||||
return NULL;
|
||||
}
|
||||
if (!(mgr = virObjectLockableNew(virSecurityManagerClass)))
|
||||
goto error;
|
||||
|
||||
mgr->drv = drv;
|
||||
mgr->flags = flags;
|
||||
mgr->virtDriver = virtDriver;
|
||||
mgr->privateData = privateData;
|
||||
VIR_STEAL_PTR(mgr->privateData, privateData);
|
||||
|
||||
if (drv->open(mgr) < 0) {
|
||||
virObjectUnref(mgr);
|
||||
return NULL;
|
||||
}
|
||||
if (drv->open(mgr) < 0)
|
||||
goto error;
|
||||
|
||||
return mgr;
|
||||
error:
|
||||
VIR_FREE(privateData);
|
||||
virObjectUnref(mgr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user