xen/18588-do-get-pm-info.patch

40 lines
1.3 KiB
Diff

# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1223629254 -3600
# Node ID a175b2c039ed2481e4064a8256bd29f15c98d0d1
# Parent 8f5a67f466e297535f84cc88eaaa2e71f37f2963
acpi/pmstat.c: refer to the array after range check.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Index: xen-3.3.1-testing/xen/arch/x86/acpi/pmstat.c
===================================================================
--- xen-3.3.1-testing.orig/xen/arch/x86/acpi/pmstat.c
+++ xen-3.3.1-testing/xen/arch/x86/acpi/pmstat.c
@@ -49,17 +49,20 @@ extern int pmstat_reset_cx_stat(uint32_t
int do_get_pm_info(struct xen_sysctl_get_pmstat *op)
{
int ret = 0;
- struct pm_px *pxpt = &px_statistic_data[op->cpuid];
- struct processor_pminfo *pmpt = &processor_pminfo[op->cpuid];
+ struct pm_px *pxpt;
+ const struct processor_pminfo *pmpt;
+
+ if ( (op->cpuid >= NR_CPUS) || !cpu_online(op->cpuid) )
+ return -EINVAL;
+
+ pmpt = processor_pminfo[op->cpuid];
+ pxpt = &px_statistic_data[op->cpuid];
/* to protect the case when Px was not controlled by xen */
if ( (!(pmpt->perf.init & XEN_PX_INIT)) &&
(op->type & PMSTAT_CATEGORY_MASK) == PMSTAT_PX )
return -EINVAL;
- if ( !cpu_online(op->cpuid) )
- return -EINVAL;
-
switch( op->type )
{
case PMSTAT_get_max_px: