]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSecuritySELinuxGetProcessLabel: Automatically free 'ctx' temp variable
authorPeter Krempa <pkrempa@redhat.com>
Fri, 18 Jul 2025 14:19:26 +0000 (16:19 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 22 Jul 2025 14:52:36 +0000 (16:52 +0200)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/security/security_selinux.c

index 3004320380644ba93c2d4f630239dde8f79bb8b2..54f12d044f31063c7e5431b8f2236a7cf2f823b6 100644 (file)
@@ -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) {