From: Paul Floyd Date: Sat, 30 Sep 2023 19:54:21 +0000 (+0200) Subject: cachegrind: exit with error if line size or associativity is zero X-Git-Tag: VALGRIND_3_22_0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc25e4c552ee400c8ed90e64c93a9b6c1229847b;p=thirdparty%2Fvalgrind.git cachegrind: exit with error if line size or associativity is zero Detected with Coverity --- diff --git a/cachegrind/cg_arch.c b/cachegrind/cg_arch.c index 9b6071d2c3..dac22feb2a 100644 --- a/cachegrind/cg_arch.c +++ b/cachegrind/cg_arch.c @@ -41,6 +41,16 @@ static void configure_caches(cache_t* I1c, cache_t* D1c, cache_t* LLc, // string otherwise. static const HChar* check_cache(cache_t* cache) { + if (cache->line_size == 0) + { + return "Cache line size is zero.\n"; + } + + if (cache->assoc == 0) + { + return "Cache associativity is zero.\n"; + } + // Simulator requires set count to be a power of two. if ((cache->size % (cache->line_size * cache->assoc) != 0) || (-1 == VG_(log2)(cache->size/cache->line_size/cache->assoc)))