aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/arch/x86
diff options
context:
space:
mode:
authorJuha-Matti Tilli <juha-matti.tilli@nokia.com>2016-03-30 09:06:42 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-03-31 16:48:37 +0300
commit16cc12ae1b913d86084ae59cb2597499e7f727df (patch)
tree498ea691dcaa7670818ef07b74b27a078603b4c1 /platform/linux-generic/arch/x86
parent972f47f4672cb30f0cb50a3ddfc0ced69eb27729 (diff)
linux-generic: sysinfo: handle missing @ sign in CPU model
Previously, the sysinfo cpuinfo parser assumed that every CPU model has an @ sign, after which comes the maximum CPU frequency. However, many environments such as virtualized KVM environments have CPU models not having @ sign such as "Intel Xeon E312xx (Sandy Bridge)". The result of the missing @ sign was that the ODP program crashed. The fix is to not assume the @ sign is always there. This may leave cpu_hz_max uninitialized, but then again this is already what is done if the string after @ does not conform to the pattern. Signed-off-by: Juha-Matti Tilli <juha-matti.tilli@nokia.com> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/arch/x86')
-rw-r--r--platform/linux-generic/arch/x86/odp_sysinfo_parse.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index 2ef49e434..c1e05c023 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -24,10 +24,12 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
sizeof(sysinfo->model_str[id]) - 1);
pos = strchr(sysinfo->model_str[id], '@');
- *(pos - 1) = '\0';
- if (sscanf(pos, "@ %lfGHz", &ghz) == 1) {
- hz = (uint64_t)(ghz * 1000000000.0);
- sysinfo->cpu_hz_max[id] = hz;
+ if (pos) {
+ *(pos - 1) = '\0';
+ if (sscanf(pos, "@ %lfGHz", &ghz) == 1) {
+ hz = (uint64_t)(ghz * 1000000000.0);
+ sysinfo->cpu_hz_max[id] = hz;
+ }
}
id++;
}