From: Peter Krempa <pkre...@redhat.com>

Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 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.50.0

Reply via email to