sysctl: don't overwrite array size variable when it is set on error earlier

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>
This commit is contained in:
Boris Ostrovsky authored and Jan Beulich committed 2015-03-26 11:13:01 +01:00
1 parent 28fbff96c1
commit 26da081ac9
1 file changed
+3 -1
+3 -1
View File
@@ -338,8 +338,10 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
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;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.