perf/x86/intel/uncore: Fix wrong box pointer check
authorKan Liang <kan.liang@intel.com>
Thu, 29 Jun 2017 19:09:26 +0000 (12:09 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 29 Jun 2017 19:28:13 +0000 (21:28 +0200)
Should not init a NULL box. It will cause system crash.
The issue looks like caused by a typo.

This was not noticed because there is no NULL box. Also, for most
boxes, they are enabled by default. The init code is not critical.

Fixes: fff4b87e594a ("perf/x86/intel/uncore: Make package handling more robust")
Signed-off-by: Kan Liang <kan.liang@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20170629190926.2456-1-kan.liang@intel.com
arch/x86/events/intel/uncore.c

index 758c1aa5009d2414f3165a31abb6044b6ccf0409..44ec523287f670dff8eee3e3c9eb1bb1606489b6 100644 (file)
@@ -1170,7 +1170,7 @@ static int uncore_event_cpu_online(unsigned int cpu)
                pmu = type->pmus;
                for (i = 0; i < type->num_boxes; i++, pmu++) {
                        box = pmu->boxes[pkg];
-                       if (!box && atomic_inc_return(&box->refcnt) == 1)
+                       if (box && atomic_inc_return(&box->refcnt) == 1)
                                uncore_box_init(box);
                }
        }