提交 c060e400 编写于 作者: M Michal Privoznik

virSecurityManagerNewDriver: Fix code pattern

Use 'error' label to free allocated memory.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 39015a6f
...@@ -73,8 +73,8 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv, ...@@ -73,8 +73,8 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv,
const char *virtDriver, const char *virtDriver,
unsigned int flags) unsigned int flags)
{ {
virSecurityManagerPtr mgr; virSecurityManagerPtr mgr = NULL;
char *privateData; char *privateData = NULL;
if (virSecurityManagerInitialize() < 0) if (virSecurityManagerInitialize() < 0)
return NULL; return NULL;
...@@ -87,22 +87,22 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv, ...@@ -87,22 +87,22 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv,
if (VIR_ALLOC_N(privateData, drv->privateDataLen) < 0) if (VIR_ALLOC_N(privateData, drv->privateDataLen) < 0)
return NULL; return NULL;
if (!(mgr = virObjectLockableNew(virSecurityManagerClass))) { if (!(mgr = virObjectLockableNew(virSecurityManagerClass)))
VIR_FREE(privateData); goto error;
return NULL;
}
mgr->drv = drv; mgr->drv = drv;
mgr->flags = flags; mgr->flags = flags;
mgr->virtDriver = virtDriver; mgr->virtDriver = virtDriver;
mgr->privateData = privateData; VIR_STEAL_PTR(mgr->privateData, privateData);
if (drv->open(mgr) < 0) { if (drv->open(mgr) < 0)
virObjectUnref(mgr); goto error;
return NULL;
}
return mgr; return mgr;
error:
VIR_FREE(privateData);
virObjectUnref(mgr);
return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册