Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753381AbdF2TLp (ORCPT ); Thu, 29 Jun 2017 15:11:45 -0400 Received: from mga01.intel.com ([192.55.52.88]:20649 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751752AbdF2TLi (ORCPT ); Thu, 29 Jun 2017 15:11:38 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,282,1496127600"; d="scan'208";a="120491944" From: kan.liang@intel.com To: tglx@linutronix.de, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH] perf/x86/intel/uncore: fix wrong box pointer check Date: Thu, 29 Jun 2017 12:09:26 -0700 Message-Id: <20170629190926.2456-1-kan.liang@intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1030 Lines: 31 From: Kan Liang Should not init a NULL box. It will cause system crash. The issue looks like caused by a typo. It is introduced from: commit fff4b87e594a ("perf/x86/intel/uncore: Make package handling more robust") 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. Signed-off-by: Kan Liang --- arch/x86/events/intel/uncore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } } -- 2.11.0