aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2014-10-01 01:03:20 -0400
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2014-10-08 05:43:24 +0300
commite17edc46405d1150bf3f4a8433c9fddaa5082858 (patch)
tree34e5e8462f7972bb1bbdf72e6b7b0e32521a0ec1
parentcbebd248d51c516d8d175f08175d28ebee338045 (diff)
Fix segfault when no C-state names are available
Signed-off-by: Nicolas Pitre <nico@linaro.org> Reviewed-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
-rw-r--r--idlestat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/idlestat.c b/idlestat.c
index da615cb..6d63946 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -1148,10 +1148,11 @@ struct cpuidle_cstates *physical_cluster_data(struct cpu_physical *s_phy)
if (!cstates)
continue;
}
- /* copy state name from first core */
+ /* copy state name from first core (if any) */
s_core = list_first_entry(&s_phy->core_head, struct cpu_core,
list_core);
- cstates->name = strdup(s_core->cstates->cstate[i].name);
+ cstates->name = s_core->cstates->cstate[i].name ?
+ strdup(s_core->cstates->cstate[i].name) : NULL;
result->cstate[i] = *cstates;
}