]> xenbits.xensource.com Git - libvirt.git/commitdiff
selinux: Only close the selabel_handle once
authorJán Tomko <jtomko@redhat.com>
Tue, 1 Oct 2013 11:15:12 +0000 (13:15 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 1 Oct 2013 13:00:07 +0000 (15:00 +0200)
On selinux driver initialization failure (missing/incorrectly
formatted contexts file), selabel_handle was closed twice.

Introduced by 6159710.

src/security/security_selinux.c

index 38de06076b017441c36698041d0d0bcdcd609181..c408fa8fbc170a99e86834ea2aec8edbb480ff62 100644 (file)
@@ -460,6 +460,7 @@ virSecuritySELinuxLXCInitialize(virSecurityManagerPtr mgr)
 error:
 # if HAVE_SELINUX_LABEL_H
     selabel_close(data->label_handle);
+    data->label_handle = NULL;
 # endif
     virConfFree(selinux_conf);
     VIR_FREE(data->domain_context);
@@ -547,6 +548,7 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPtr mgr)
 error:
 #if HAVE_SELINUX_LABEL_H
     selabel_close(data->label_handle);
+    data->label_handle = NULL;
 #endif
     VIR_FREE(data->domain_context);
     VIR_FREE(data->alt_domain_context);
@@ -808,7 +810,8 @@ virSecuritySELinuxSecurityDriverClose(virSecurityManagerPtr mgr)
         return 0;
 
 #if HAVE_SELINUX_LABEL_H
-    selabel_close(data->label_handle);
+    if (data->label_handle)
+        selabel_close(data->label_handle);
 #endif
 
     virHashFree(data->mcs);