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.ti...@nokia.com> --- platform/linux-generic/arch/x86/odp_sysinfo_parse.c | 10 ++++++---- 1 file 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 2ef49e4..c1e05c0 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++; } -- 1.8.3.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp