sched_rt: fix memory leak in rt_init()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 8 Jun 2015 12:13:23 +0000 (14:13 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 8 Jun 2015 12:13:23 +0000 (14:13 +0200)
Introduced by c/s 376bbba "sched_rt: print useful affinity info when dumping".
If the allocation of cpumask failed, prv was leaked.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Coverity-ID: 1304398
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
xen/common/sched_rt.c

index 5836d274b2df469158838f539b7b26ebf6ea5fb5..4372486b94159283fc04423554514e85f5d92c84 100644 (file)
@@ -441,7 +441,7 @@ rt_init(struct scheduler *ops)
     {
         _cpumask_scratch = xmalloc_array(cpumask_var_t, nr_cpu_ids);
         if ( !_cpumask_scratch )
-            return -ENOMEM;
+            goto no_mem;
     }
     nr_rt_ops++;
 
@@ -455,6 +455,10 @@ rt_init(struct scheduler *ops)
     ops->sched_data = prv;
 
     return 0;
+
+ no_mem:
+    xfree(prv);
+    return -ENOMEM;
 }
 
 static void