Skip to content

Commit d06118f

Browse files
committed
ACPI: property: Disregard references in data-only subnode lists
Data-only subnode links following the ACPI data subnode GUID in a _DSD package are expected to point to named objects returning _DSD-equivalent packages. If a reference to such an object is used in the target field of any of those links, that object will be evaluated in place (as a named object) and its return data will be embedded in the outer _DSD package. For this reason, it is not expected to see a subnode link with the target field containing a local reference (that would mean pointing to a device or another object that cannot be evaluated in place and therefore cannot return a _DSD-equivalent package). Accordingly, simplify the code parsing data-only subnode links to simply print a message when it encounters a local reference in the target field of one of those links. Moreover, since acpi_nondev_subnode_data_ok() would only have one caller after the change above, fold it into that caller. Link: https://lore.kernel.org/linux-acpi/CAJZ5v0jVeSrDO6hrZhKgRZrH=FpGD4vNUjFD8hV9WwN9TLHjzQ@mail.gmail.com/ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
1 parent d0759b1 commit d06118f

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

drivers/acpi/property.c

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,12 @@ static bool acpi_nondev_subnode_extract(union acpi_object *desc,
124124
return false;
125125
}
126126

127-
static bool acpi_nondev_subnode_data_ok(acpi_handle handle,
128-
const union acpi_object *link,
129-
struct list_head *list,
130-
struct fwnode_handle *parent)
131-
{
132-
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
133-
acpi_status status;
134-
135-
status = acpi_evaluate_object_typed(handle, NULL, NULL, &buf,
136-
ACPI_TYPE_PACKAGE);
137-
if (ACPI_FAILURE(status))
138-
return false;
139-
140-
if (acpi_nondev_subnode_extract(buf.pointer, handle, link, list,
141-
parent))
142-
return true;
143-
144-
ACPI_FREE(buf.pointer);
145-
return false;
146-
}
147-
148127
static bool acpi_nondev_subnode_ok(acpi_handle scope,
149128
const union acpi_object *link,
150129
struct list_head *list,
151130
struct fwnode_handle *parent)
152131
{
132+
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
153133
acpi_handle handle;
154134
acpi_status status;
155135

@@ -161,7 +141,17 @@ static bool acpi_nondev_subnode_ok(acpi_handle scope,
161141
if (ACPI_FAILURE(status))
162142
return false;
163143

164-
return acpi_nondev_subnode_data_ok(handle, link, list, parent);
144+
status = acpi_evaluate_object_typed(handle, NULL, NULL, &buf,
145+
ACPI_TYPE_PACKAGE);
146+
if (ACPI_FAILURE(status))
147+
return false;
148+
149+
if (acpi_nondev_subnode_extract(buf.pointer, handle, link, list,
150+
parent))
151+
return true;
152+
153+
ACPI_FREE(buf.pointer);
154+
return false;
165155
}
166156

167157
static bool acpi_add_nondev_subnodes(acpi_handle scope,
@@ -174,7 +164,6 @@ static bool acpi_add_nondev_subnodes(acpi_handle scope,
174164

175165
for (i = 0; i < links->package.count; i++) {
176166
union acpi_object *link, *desc;
177-
acpi_handle handle;
178167
bool result;
179168

180169
link = &links->package.elements[i];
@@ -186,22 +175,26 @@ static bool acpi_add_nondev_subnodes(acpi_handle scope,
186175
if (link->package.elements[0].type != ACPI_TYPE_STRING)
187176
continue;
188177

189-
/* The second one may be a string, a reference or a package. */
178+
/* The second one may be a string or a package. */
190179
switch (link->package.elements[1].type) {
191180
case ACPI_TYPE_STRING:
192181
result = acpi_nondev_subnode_ok(scope, link, list,
193182
parent);
194183
break;
195-
case ACPI_TYPE_LOCAL_REFERENCE:
196-
handle = link->package.elements[1].reference.handle;
197-
result = acpi_nondev_subnode_data_ok(handle, link, list,
198-
parent);
199-
break;
200184
case ACPI_TYPE_PACKAGE:
201185
desc = &link->package.elements[1];
202186
result = acpi_nondev_subnode_extract(desc, NULL, link,
203187
list, parent);
204188
break;
189+
case ACPI_TYPE_LOCAL_REFERENCE:
190+
/*
191+
* It is not expected to see any local references in
192+
* the links package because referencing a named object
193+
* should cause it to be evaluated in place.
194+
*/
195+
acpi_handle_info(scope, "subnode %s: Unexpected reference\n",
196+
link->package.elements[0].string.pointer);
197+
fallthrough;
205198
default:
206199
result = false;
207200
break;

0 commit comments

Comments
 (0)