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:
John Ferlan 2015-02-13 14:15:26 -05:00
parent 8e6492f298
commit 5a36cdbcce

View File

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