The online_cpu_bitmap[] array size is based on the number of CPU
allocated (see sa_wrap.c:wrap_read_softnet()). The size is calculated as
BITMAP_SIZE(a->nr_allocated).
So the index used in read_softnet() function (rd_stats.c) shall not
exceed the size of the array, and so cannot reach NR_CPUS.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
while (fgets(line, sizeof(line), fp) != NULL) {
- while ((!(online_cpu_bitmap[(cpu - 1) >> 3] & (1 << ((cpu - 1) & 0x07)))) && (cpu <= NR_CPUS + 1)) {
+ while ((!(online_cpu_bitmap[(cpu - 1) >> 3] & (1 << ((cpu - 1) & 0x07)))) && (cpu < nr_alloc)) {
cpu++;
}
- if (cpu > NR_CPUS + 1)
- /* Should never happen */
- return 0;
- if (cpu + 1 > nr_alloc) {
+ if (cpu >= nr_alloc) {
rc = -1;
break;
}