From: Peter Krempa Date: Fri, 18 Jul 2025 14:19:26 +0000 (+0200) Subject: virSecuritySELinuxGetProcessLabel: Automatically free 'ctx' temp variable X-Git-Tag: v11.6.0-rc1~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f69ecd970d2001576f8575085a136622a7443de4;p=thirdparty%2Flibvirt.git virSecuritySELinuxGetProcessLabel: Automatically free 'ctx' temp variable Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 3004320380..54f12d044f 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1271,7 +1271,7 @@ virSecuritySELinuxGetProcessLabel(virSecurityManager *mgr G_GNUC_UNUSED, pid_t pid, virSecurityLabelPtr sec) { - char *ctx; + g_autofree char *ctx = NULL; if (getpidcon_raw(pid, &ctx) == -1) { virReportSystemError(errno, @@ -1284,12 +1284,9 @@ virSecuritySELinuxGetProcessLabel(virSecurityManager *mgr G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, _("security label exceeds maximum length: %1$d"), VIR_SECURITY_LABEL_BUFLEN - 1); - freecon(ctx); return -1; } - freecon(ctx); - VIR_DEBUG("label=%s", sec->label); sec->enforcing = security_getenforce(); if (sec->enforcing == -1) {