xen/time: Check that the per_cpu data structure has data before freeing.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 4 Jun 2013 21:11:52 +0000 (17:11 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 10 Jun 2013 12:43:36 +0000 (08:43 -0400)
We don't check whether the per_cpu data structure has actually
been freed in the past. This checks it and if it has been freed
in the past then just continues on without double-freeing.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/time.c

index 011f1bf85765390931e524f76842152abaa33fdf..6a56ae092994b5da2bb817ff13d3925a8635b2d5 100644 (file)
@@ -434,10 +434,13 @@ void xen_teardown_timer(int cpu)
        struct clock_event_device *evt;
        BUG_ON(cpu == 0);
        evt = &per_cpu(xen_clock_events, cpu).evt;
-       unbind_from_irqhandler(evt->irq, NULL);
-       evt->irq = -1;
-       kfree(per_cpu(xen_clock_events, cpu).name);
-       per_cpu(xen_clock_events, cpu).name = NULL;
+
+       if (evt->irq >= 0) {
+               unbind_from_irqhandler(evt->irq, NULL);
+               evt->irq = -1;
+               kfree(per_cpu(xen_clock_events, cpu).name);
+               per_cpu(xen_clock_events, cpu).name = NULL;
+       }
 }
 
 void xen_setup_cpu_clockevents(void)