When querying CPU topology, if caller-provided array size is smaller than
number of online CPUs then, in addition to returning -ENOBUFS, sysctl is
expected to provide back this number. However, this value, stored in 'i',
is overwritten in the subsequent loop's control statement.
Make sure we don't do this by converting the loop to 'while'.
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
ret = -ENOBUFS;
i = num_cpus;
}
+ else
+ i = 0;
- for ( i = 0; i < num_cpus; i++ )
+ for ( ; i < num_cpus; i++ )
{
xen_sysctl_cputopo_t cputopo;