mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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:
1 parent
28fbff96c1
commit
26da081ac9
1 file changed
+3
-1
+3
-1
@@ -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;
|
||||
|
||||
|
||||