Skip to content

Commit 9cc8cd0

Browse files
superm1rafaeljw
authored andcommitted
ACPI: x86: s2idle: Fix a logic error parsing AMD constraints table
The constraints table should be resetting the `list` object after running through all of `info_obj` iterations. This adjusts whitespace as well as less code will now be included with each loop. This fixes a functional problem is fixed where a badly formed package in the inner loop may have incorrect data. Fixes: 146f1ed ("ACPI: PM: s2idle: Add AMD support to handle _DSM") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 883cf0d commit 9cc8cd0

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

drivers/acpi/x86/s2idle.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,11 @@ static void lpi_device_get_constraints_amd(void)
135135
struct lpi_constraints *list;
136136
acpi_status status;
137137

138+
list = &lpi_constraints_table[lpi_constraints_table_size];
139+
138140
for (k = 0; k < info_obj->package.count; k++) {
139141
union acpi_object *obj = &info_obj->package.elements[k];
140142

141-
list = &lpi_constraints_table[lpi_constraints_table_size];
142-
list->min_dstate = -1;
143-
144143
switch (k) {
145144
case 0:
146145
dev_info.enabled = obj->integer.value;
@@ -155,27 +154,21 @@ static void lpi_device_get_constraints_amd(void)
155154
dev_info.min_dstate = obj->integer.value;
156155
break;
157156
}
157+
}
158158

159-
if (!dev_info.enabled || !dev_info.name ||
160-
!dev_info.min_dstate)
161-
continue;
159+
if (!dev_info.enabled || !dev_info.name ||
160+
!dev_info.min_dstate)
161+
continue;
162162

163-
status = acpi_get_handle(NULL, dev_info.name,
164-
&list->handle);
165-
if (ACPI_FAILURE(status))
166-
continue;
163+
status = acpi_get_handle(NULL, dev_info.name, &list->handle);
164+
if (ACPI_FAILURE(status))
165+
continue;
167166

168-
acpi_handle_debug(lps0_device_handle,
169-
"Name:%s\n", dev_info.name);
167+
acpi_handle_debug(lps0_device_handle,
168+
"Name:%s\n", dev_info.name);
170169

171-
list->min_dstate = dev_info.min_dstate;
170+
list->min_dstate = dev_info.min_dstate;
172171

173-
if (list->min_dstate < 0) {
174-
acpi_handle_debug(lps0_device_handle,
175-
"Incomplete constraint defined\n");
176-
continue;
177-
}
178-
}
179172
lpi_constraints_table_size++;
180173
}
181174
}

0 commit comments

Comments
 (0)