flask: fix memory leaks
authorJan Beulich <jbeulich@suse.com>
Tue, 11 Feb 2014 10:11:48 +0000 (11:11 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Feb 2014 10:11:48 +0000 (11:11 +0100)
Plus, in the case of security_preserve_bools(), prevent double freeing
in the case of security_get_bools() failing.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
xen/xsm/flask/flask_op.c
xen/xsm/flask/ss/services.c

index 4b93e71e77e367e582da15cdb3d9aadc3f95b86f..e4b07eb04ee4734fe33642a359baea272bfdf937 100644 (file)
@@ -347,6 +347,7 @@ static int flask_security_set_bool(struct xen_flask_boolean *arg)
 
         if ( arg->bool_id >= num )
         {
+            xfree(values);
             rv = -ENOENT;
             goto out;
         }
index 5cb9537be1d8dfe2daa1ea0a985f2e7303584e98..60673175b77f28e0726e2a8002f6c201b3148f03 100644 (file)
@@ -1902,6 +1902,7 @@ err:
     {
         for ( i = 0; i < *len; i++ )
             xfree((*names)[i]);
+        xfree(*names);
     }
     xfree(*values);
     goto out;
@@ -2011,7 +2012,7 @@ static int security_preserve_bools(struct policydb *p)
 
     rc = security_get_bools(&nbools, &bnames, &bvalues, NULL);
     if ( rc )
-        goto out;
+        return rc;
     for ( i = 0; i < nbools; i++ )
     {
         booldatum = hashtab_search(p->p_bools.table, bnames[i]);