please  review.

Maxim.

On 02/25/16 12:52, [email protected] wrote:
From: Hongbo Zhang <[email protected]>

This is for https://bugs.linaro.org/show_bug.cgi?id=2033
If the model string doesn't include speed info, segfault should
be avoided.

Signed-off-by: Hongbo Zhang <[email protected]>
---
  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++;
                }

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to