]>
x86/pmstat: correct PMSTAT_get_pxstat buffer size checking
authorJan Beulich <jbeulich@suse.com>
Wed, 18 Jun 2025 07:25:09 +0000 (09:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 18 Jun 2025 07:25:09 +0000 (09:25 +0200)
commitfb16c7411d6e1278155c144fd3310a12f2efbf5e
tree5d7cad1945b132b0b370a1defedc65e09876e867
parent25972d5b5c26afbfceb1284cdab0404a46a0baf0
x86/pmstat: correct PMSTAT_get_pxstat buffer size checking

min(pmpt->perf.state_count, op->u.getpx.total) == op->u.getpx.total can
be expressed differently as pmpt->perf.state_count >= op->u.getpx.total.
Copying when the two are equal is fine; (partial) copying when the state
count is larger than the number of array elements that a buffer was
allocated to hold is what - as per the comment - we mean to avoid. Drop
the use of min() again, but retain its effect for the subsequent copying
from pxpt->u.pt.

Fixes: aa70996a6896 ("x86/pmstat: Check size of PMSTAT_get_pxstat buffers")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
xen/drivers/acpi/pmstat.c