Skip to content

Commit

Permalink
Ensure that processors are non-null before trying to get their cores
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 585695454
  • Loading branch information
Ruy Contributors authored and copybara-github committed Nov 27, 2023
1 parent 6ffa93a commit 0ffaf3b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ruy/cpuinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ void QueryCacheParams(CpuCacheParams* cache_params) {
if (!cache->processor_count) {
continue; // crashes from Chrome on Android suggests that might happen?
}
const bool is_local =
cpuinfo_get_processor(cache->processor_start)->core ==
cpuinfo_get_processor(cache->processor_start +
cache->processor_count - 1)
->core;
const cpuinfo_processor* processor_start =
cpuinfo_get_processor(cache->processor_start);
const cpuinfo_processor* processor_end = cpuinfo_get_processor(
cache->processor_start + cache->processor_count - 1);
if (!processor_start || !processor_end) {
continue; // crashes from Chrome on Android suggests this might happen?
}
const bool is_local = processor_start->core == processor_end->core;
if (is_local) {
local_cache_size = cache->size;
}
Expand Down

0 comments on commit 0ffaf3b

Please sign in to comment.