diff options
author | Can Erkin Acar <canacar@cvs.openbsd.org> | 2007-11-14 20:22:12 +0000 |
---|---|---|
committer | Can Erkin Acar <canacar@cvs.openbsd.org> | 2007-11-14 20:22:12 +0000 |
commit | 6a3fa537623fd6ebe244da9288628fe00b67f6d1 (patch) | |
tree | 36e1aa3200f33090ed086b6f612f5e8cf613af03 /sys/dev | |
parent | abfebdb37cc60bf30be8c6635654d6e3c92055f8 (diff) |
Fix handling of local AML variables for type conversion:
Check whether a variable is local before and after dereferencing.
Improve the check to make sure that the variable is in
local in current scope.
Tested by many, thanks a lot. ok marco@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/acpi/dsdt.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c index 5c40e40904d..fcfa4afc3da 100644 --- a/sys/dev/acpi/dsdt.c +++ b/sys/dev/acpi/dsdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsdt.c,v 1.100 2007/11/10 17:53:16 chl Exp $ */ +/* $OpenBSD: dsdt.c,v 1.101 2007/11/14 20:22:11 canacar Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org> * @@ -1603,9 +1603,19 @@ aml_copyvalue(struct aml_value *lhs, struct aml_value *rhs) int is_local(struct aml_scope *, struct aml_value *); -int is_local(struct aml_scope *scope, struct aml_value *val) +int +is_local(struct aml_scope *scope, struct aml_value *val) { - return val->stack; + int idx; + + if (val->stack == 0 || scope->locals == NULL) + return (0); + + idx = val->stack - AMLOP_LOCAL0; + if (idx < 0 || idx >= AML_MAX_LOCAL) + aml_die("Invalid stack value!"); + + return (val == &scope->locals[idx]); } /* Guts of the code: Assign one value to another. LHS may contain a previous value */ @@ -1621,13 +1631,13 @@ aml_setvalue(struct aml_scope *scope, struct aml_value *lhs, rhs = _aml_setvalue(&tmpint, AML_OBJTYPE_INTEGER, ival, NULL); } + if (!is_local(scope, lhs)) + lhs = aml_dereftarget(scope, lhs); + if (is_local(scope, lhs)) { /* ACPI: Overwrite writing to LocalX */ aml_freevalue(lhs); } - else { - lhs = aml_dereftarget(scope, lhs); - } switch (lhs->type) { case AML_OBJTYPE_UNINITIALIZED: |