From: Kan Liang Date: Thu, 29 Jun 2017 19:09:26 +0000 (-0700) Subject: perf/x86/intel/uncore: Fix wrong box pointer check X-Git-Tag: v4.11.9~39 X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdbe850337374f8aeb49a2d40b9cfe277bbdfcb1;p=linux perf/x86/intel/uncore: Fix wrong box pointer check commit 80c65fdb4c6920e332a9781a3de5877594b07522 upstream. 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 Signed-off-by: Thomas Gleixner Link: http://lkml.kernel.org/r/20170629190926.2456-1-kan.liang@intel.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 758c1aa5009d..44ec523287f6 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -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); } }