[PATCH 15/19] virSecuritySELinuxGetProcessLabel: Automatically free 'ctx' temp variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Krempa <pkrempa@xxxxxxxxxx>

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux