Skip to content

Commit 16b7c27

Browse files
praritrafaeljw
authored andcommitted
tools: cpupower: fix return checks for sysfs_get_idlestate_count()
Red Hat and Fedora use a bug reporting tool that gathers data about "broken" systems called sosreport. Among other things, it includes the output of 'cpupower idle-info'. Executing 'cpupower idle-info' on a system that has cpuidle disabled via 'cpuidle.off=1' results in a 300 second hang in the cpupower application. ie) [root@intel-brickland-05]# cpupower idle-info Could not determine cpuidle driver Analyzing CPU 0: Number of idle states: -19 [hang] The problem is that the cpupower code only checks for a zero return from sysfs_get_idlestate_count(). The function can return -ENODEV (-19) as above. This patch fixes callers to sysfs_get_idlestate_count() to check the right return values. Signed-off-by: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 009d043 commit 16b7c27

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/power/cpupower/utils/cpuidle-info.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
static void cpuidle_cpu_output(unsigned int cpu, int verbose)
2424
{
25-
unsigned int idlestates, idlestate;
25+
int idlestates, idlestate;
2626
char *tmp;
2727

2828
printf(_ ("Analyzing CPU %d:\n"), cpu);
2929

3030
idlestates = sysfs_get_idlestate_count(cpu);
31-
if (idlestates == 0) {
31+
if (idlestates < 1) {
3232
printf(_("CPU %u: No idle states\n"), cpu);
3333
return;
3434
}
@@ -100,10 +100,10 @@ static void cpuidle_general_output(void)
100100
static void proc_cpuidle_cpu_output(unsigned int cpu)
101101
{
102102
long max_allowed_cstate = 2000000000;
103-
unsigned int cstate, cstates;
103+
int cstate, cstates;
104104

105105
cstates = sysfs_get_idlestate_count(cpu);
106-
if (cstates == 0) {
106+
if (cstates < 1) {
107107
printf(_("CPU %u: No C-states info\n"), cpu);
108108
return;
109109
}

0 commit comments

Comments
 (0)