mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
security: Resolve Coverity RESOURCE_LEAK
Introduced by commit id 'c3d9d3bb' - return from virSecurityManagerCheckModel wasn't VIR_FREE()'ing the virSecurityManagerGetNested allocated memory.
This commit is contained in:
parent
8e6492f298
commit
5a36cdbcce
@ -688,24 +688,29 @@ virSecurityManagerReleaseLabel(virSecurityManagerPtr mgr,
|
||||
static int virSecurityManagerCheckModel(virSecurityManagerPtr mgr,
|
||||
char *secmodel)
|
||||
{
|
||||
int ret = -1;
|
||||
size_t i;
|
||||
virSecurityManagerPtr *sec_managers = NULL;
|
||||
|
||||
if ((sec_managers = virSecurityManagerGetNested(mgr)) == NULL)
|
||||
return -1;
|
||||
|
||||
if (STREQ_NULLABLE(secmodel, "none"))
|
||||
return 0;
|
||||
|
||||
if ((sec_managers = virSecurityManagerGetNested(mgr)) == NULL)
|
||||
return -1;
|
||||
|
||||
for (i = 0; sec_managers[i]; i++) {
|
||||
if (STREQ_NULLABLE(secmodel, sec_managers[i]->drv->name))
|
||||
return 0;
|
||||
if (STREQ_NULLABLE(secmodel, sec_managers[i]->drv->name)) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unable to find security driver for model %s"),
|
||||
secmodel);
|
||||
return -1;
|
||||
cleanup:
|
||||
VIR_FREE(sec_managers);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user