]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/timers: Fix memory leak with cpu unplug/plug (take 2)
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 23 Apr 2019 15:18:29 +0000 (16:18 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 13 May 2019 09:35:37 +0000 (10:35 +0100)
Previous attempts to fix this leak didn't identify the root cause, and
ultimately failed.  The cause is actually the CPU_UP_PREPARE case
(re)initialising ts->heap back to dummy_heap, which leaks the previous
allocation.

Rearrange the logic to only initialise ts once.  This also avoids the
redundant (but benign, due to ts->inactive always being empty) initialising of
the other ts fields.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/timer.c

index 9ee500b3a7f99e12b6fe45ed1057f45f8a5e7b53..c85273bf82dfd75796e305eedb66997300c595c9 100644 (file)
@@ -638,9 +638,13 @@ static int cpu_callback(
     switch ( action )
     {
     case CPU_UP_PREPARE:
-        INIT_LIST_HEAD(&ts->inactive);
-        spin_lock_init(&ts->lock);
-        ts->heap = dummy_heap;
+        /* Only initialise ts once. */
+        if ( !ts->heap )
+        {
+            INIT_LIST_HEAD(&ts->inactive);
+            spin_lock_init(&ts->lock);
+            ts->heap = dummy_heap;
+        }
         break;
 
     case CPU_UP_CANCELED: