kernel/system_info: Check bounded "count" instead of the unbounded one.

This condition should never be hit by well-behaved applications
anyways.
This commit is contained in:
Augustin Cavalier 2019-07-27 13:51:46 -04:00
parent 538a30f8db
commit 68d11f88e9

View File

@ -495,10 +495,10 @@ get_cpu_info(uint32 firstCPU, uint32 cpuCount, cpu_info* info)
{
if (firstCPU >= (uint32)smp_get_num_cpus())
return B_BAD_VALUE;
if (cpuCount == 0)
return B_OK;
uint32 count = std::min(cpuCount, smp_get_num_cpus() - firstCPU);
if (count <= 0)
return B_OK;
// This function is called very often from userland by applications
// that display CPU usage information, so we want to keep this as