From f69ecd970d2001576f8575085a136622a7443de4 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 18 Jul 2025 16:19:26 +0200 Subject: [PATCH] virSecuritySELinuxGetProcessLabel: Automatically free 'ctx' temp variable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/security/security_selinux.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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) { -- 2.47.2