Skip to content

plugins/cpu: Test for the proper CPU property, skip nonexistent CPUs

Hector Martin requested to merge marcan/ksystemstats:fix-cpu-plugin into master

Commit 478e766d regressed ksystemstats on many ARM systems, since it mistakenly tests the "cpu" property of the CPU object (which is is the "physical id") and not the "id" property (which is the actual CPU number). For systems without a "physical id", this ignores all CPUs and ends up crashing on a NULL deref later when it tries to look up CPU numbers from /proc/stat.

Fix the incorrect check and add an extra NULL guard, so if we fail to parse /proc/cpuinfo properly we don't crash. We only need an "id" property to consider the CPU object valid, and that property is required to identify the CPU in the first place, so it is the only one that needs to be tested.

BUG: 495524 Fixes: 478e766d ("plugins/cpu: Ignore invalid CPU info when reading /proc/cpuinfo")

Edited by Hector Martin

Merge request reports

Loading