Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi Properly protect against garbage values.



details:   https://anonhg.NetBSD.org/src/rev/ca831e704626
branches:  trunk
changeset: 757048:ca831e704626
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Wed Aug 11 18:15:52 2010 +0000

description:
Properly protect against garbage values.

diffstat:

 sys/dev/acpi/acpi_cpu_pstate.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (50 lines):

diff -r 2e8b383a5d2d -r ca831e704626 sys/dev/acpi/acpi_cpu_pstate.c
--- a/sys/dev/acpi/acpi_cpu_pstate.c    Wed Aug 11 17:28:59 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_pstate.c    Wed Aug 11 18:15:52 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.12 2010/08/11 16:41:19 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.13 2010/08/11 18:15:52 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.12 2010/08/11 16:41:19 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.13 2010/08/11 18:15:52 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -305,8 +305,10 @@
                ps = &sc->sc_pstate[i];
                rv = acpicpu_pstate_pss_add(ps, &obj->Package.Elements[i]);
 
-               if (ACPI_FAILURE(rv))
+               if (ACPI_FAILURE(rv)) {
+                       ps->ps_freq = 0;
                        continue;
+               }
 
                for (j = 0; j < i; j++) {
 
@@ -356,9 +358,6 @@
                val[i] = elm[i].Integer.Value;
        }
 
-       if (val[0] == 0 || val[0] >= 0xFFFF)
-               return AE_BAD_DECIMAL_CONSTANT;
-
        CTASSERT(sizeof(val) == sizeof(struct acpicpu_pstate) -
                 offsetof(struct acpicpu_pstate, ps_freq));
 
@@ -367,6 +366,9 @@
        for (i = 0; i < 6; i++, p++)
                *p = val[i];
 
+       if (ps->ps_freq == 0 || ps->ps_freq > 9999)
+               return AE_BAD_DECIMAL_CONSTANT;
+
        /*
         * The latency is typically around 10 usec
         * on Intel CPUs. Use that as the minimum.



Home | Main Index | Thread Index | Old Index