Skip to contentSkip to conversation

perf/x86/intel/uncore: fix wrong box pointer check

PATCH New [email protected] 2 participants 2 messages Jun 29, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/x86/intel/uncore: fix wrong box pointer check

From: Kan Liang <[email protected]>

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.

---
 arch/x86/events/intel/uncore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/uncore.c +1 -1
index 758c1aa5009d..44ec523287f6 100644
@@ -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);
 		}
 	}
Signature · 1 line
2.11.0
#1 lore raw

[tip:x86/urgent] perf/x86/intel/uncore: Fix wrong box pointer check

perf/x86/intel/uncore: Fix wrong box pointer check
Commit-ID:  80c65fdb4c6920e332a9781a3de5877594b07522
Gitweb:     http://git.kernel.org/tip/80c65fdb4c6920e332a9781a3de5877594b07522
Author:     Kan Liang <[email protected]>
AuthorDate: Thu, 29 Jun 2017 12:09:26 -0700
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Thu, 29 Jun 2017 21:28:13 +0200

perf/x86/intel/uncore: Fix wrong box pointer check

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")
---
 arch/x86/events/intel/uncore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/uncore.c +1 -1
index 758c1aa..44ec523 100644
@@ -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);
 		}
 	}