x86 / perf: Fix suspend to RAM on HP nx6325
authorRafael J. Wysocki <rjw@sisk.pl>
Sun, 21 Mar 2010 20:51:51 +0000 (21:51 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 22 Mar 2010 16:57:19 +0000 (09:57 -0700)
Commit 3f6da3905398826d85731247e7fbcf53400c18bd
(perf: Rework and fix the arch CPU-hotplug hooks) broke suspend to
RAM on my HP nx6325 (and most likely on other AMD-based boxes too)
by allowing amd_pmu_cpu_offline() to be executed for CPUs that are
going offline as part of the suspend process.  The problem is that
cpuhw->amd_nb may be NULL already, so the function should make sure
it's not NULL before accessing the object pointed to by it.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/kernel/cpu/perf_event_amd.c

index 573458f1caf23c91ab39930fc0613cf78d27d55f..b87e0b6970cbc363d2a6c4b233796416176ba09e 100644 (file)
@@ -348,10 +348,12 @@ static void amd_pmu_cpu_offline(int cpu)
 
        raw_spin_lock(&amd_nb_lock);
 
-       if (--cpuhw->amd_nb->refcnt == 0)
-               kfree(cpuhw->amd_nb);
+       if (cpuhw->amd_nb) {
+               if (--cpuhw->amd_nb->refcnt == 0)
+                       kfree(cpuhw->amd_nb);
 
-       cpuhw->amd_nb = NULL;
+               cpuhw->amd_nb = NULL;
+       }
 
        raw_spin_unlock(&amd_nb_lock);
 }