{
int ret = -1;
virSecurityLabelDef *secdef;
- char *path;
secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
if (secdef == NULL)
switch (dev->source.caps.type) {
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE: {
+ g_autofree char *path = NULL;
if (vroot) {
path = g_strdup_printf("%s/%s", vroot,
dev->source.caps.u.storage.block);
path = g_strdup(dev->source.caps.u.storage.block);
}
ret = virSecuritySELinuxSetFilecon(mgr, path, secdef->imagelabel, true);
- VIR_FREE(path);
break;
}
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC: {
+ g_autofree char *path = NULL;
if (vroot) {
path = g_strdup_printf("%s/%s", vroot,
dev->source.caps.u.misc.chardev);
path = g_strdup(dev->source.caps.u.misc.chardev);
}
ret = virSecuritySELinuxSetFilecon(mgr, path, secdef->imagelabel, true);
- VIR_FREE(path);
break;
}
const char *vroot)
{
int ret = -1;
- char *path;
switch (dev->source.caps.type) {
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE: {
+ g_autofree char *path = NULL;
if (vroot) {
path = g_strdup_printf("%s/%s", vroot,
dev->source.caps.u.storage.block);
path = g_strdup(dev->source.caps.u.storage.block);
}
ret = virSecuritySELinuxRestoreFileLabel(mgr, path, true);
- VIR_FREE(path);
break;
}
case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC: {
+ g_autofree char *path = NULL;
if (vroot) {
path = g_strdup_printf("%s/%s", vroot,
dev->source.caps.u.misc.chardev);
path = g_strdup(dev->source.caps.u.misc.chardev);
}
ret = virSecuritySELinuxRestoreFileLabel(mgr, path, true);
- VIR_FREE(path);
break;
}