Skip to contentSkip to conversation

x86/hpet: fix cpumask allocation after 23990:1c8789852eaf

PATCH In review Jan Beulich 2 participants 2 messages Oct 21, 2011 – Oct 24, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hpet: fix cpumask allocation after 23990:1c8789852eaf

hpet_fsb_cap_lookup(), if it doesn't find any FSB capable timer, leaves hpet_events allocated, while hpet_events->cpumask may not have been, As we're pretty generous with these one-time allocations already (in that hpet_events doesn't get freed when no usable counters were found, even if in that case only the first array entry [or none at all] may get used), simply make the cpumask allocation in the legacy case independent of whether hpet_events was NULL before.

xen/arch/x86/hpet.c +1 -8
@@ -512,15 +512,8 @@ void __init hpet_broadcast_init(void)
             return;
 
         if ( !hpet_events )
-        {
             hpet_events = xzalloc(struct hpet_event_channel);
-            if ( hpet_events && !zalloc_cpumask_var(&hpet_events->cpumask) )
-            {
-                xfree(hpet_events);
-                hpet_events = NULL;
-            }
-        }
-        if ( !hpet_events )
+        if ( !hpet_events || !zalloc_cpumask_var(&hpet_events->cpumask) )
             return;
         hpet_events->irq = -1;
 

x86/hpet: fix cpumask allocation after 23990:1c8789852eaf

hpet_fsb_cap_lookup(), if it doesn't find any FSB capable timer, leaves hpet_events allocated, while hpet_events->cpumask may not have been, As we're pretty generous with these one-time allocations already (in that hpet_events doesn't get freed when no usable counters were found, even if in that case only the first array entry [or none at all] may get used), simply make the cpumask allocation in the legacy case independent of whether hpet_events was NULL before.

xen/arch/x86/hpet.c +1 -8
@@ -512,15 +512,8 @@ void __init hpet_broadcast_init(void)
             return;
 
         if ( !hpet_events )
-        {
             hpet_events = xzalloc(struct hpet_event_channel);
-            if ( hpet_events && !zalloc_cpumask_var(&hpet_events->cpumask) )
-            {
-                xfree(hpet_events);
-                hpet_events = NULL;
-            }
-        }
-        if ( !hpet_events )
+        if ( !hpet_events || !zalloc_cpumask_var(&hpet_events->cpumask) )
             return;
         hpet_events->irq = -1;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Tested-by Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jan Beulich

hpet_fsb_cap_lookup(), if it doesn't find any FSB capable timer, leaves hpet_events allocated, while hpet_events->cpumask may not have been, As we're pretty generous with these one-time allocations already (in that hpet_events doesn't get freed when no usable counters were found, even if in that case only the first array entry [or none at all] may get used), simply make the cpumask allocation in the legacy case independent of whether hpet_events was NULL before.

Quoted 22 lines
xen/arch/x86/hpet.c +1 -8
@@ -512,15 +512,8 @@ void __init hpet_broadcast_init(void)
              return;
 
          if ( !hpet_events )
-        {
              hpet_events = xzalloc(struct hpet_event_channel);
-            if ( hpet_events&&  !zalloc_cpumask_var(&hpet_events->cpumask) )
-            {
-                xfree(hpet_events);
-                hpet_events = NULL;
-            }
-        }
-        if ( !hpet_events )
+        if ( !hpet_events || !zalloc_cpumask_var(&hpet_events->cpumask) )
              return;
          hpet_events->irq = -1;
 
Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632