Skip to content

Commit baf60d5

Browse files
committed
ACPI: property: Do not pass NULL handles to acpi_attach_data()
In certain circumstances, the ACPI handle of a data-only node may be NULL, in which case it does not make sense to attempt to attach that node to an ACPI namespace object, so update the code to avoid attempts to do so. This prevents confusing and unuseful error messages from being printed. Also document the fact that the ACPI handle of a data-only node may be NULL and when that happens in a code comment. In addition, make acpi_add_nondev_subnodes() print a diagnostic message for each data-only node with an unknown ACPI namespace scope. Fixes: 1d52f10 ("ACPI: property: Tie data nodes to acpi handles") Cc: 6.0+ <stable@vger.kernel.org> # 6.0+ 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 737c3a0 commit baf60d5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/acpi/property.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ static bool acpi_nondev_subnode_extract(union acpi_object *desc,
124124
result = true;
125125

126126
if (result) {
127+
/*
128+
* This will be NULL if the desc package is embedded in an outer
129+
* _DSD-equivalent package and its scope cannot be determined.
130+
*/
127131
dn->handle = handle;
128132
dn->data.pointer = desc;
129133
list_add_tail(&dn->sibling, list);
@@ -224,6 +228,8 @@ static bool acpi_add_nondev_subnodes(acpi_handle scope,
224228
* strings because there is no way to build full
225229
* pathnames out of them.
226230
*/
231+
acpi_handle_debug(scope, "subnode %s: Unknown scope\n",
232+
link->package.elements[0].string.pointer);
227233
desc = &link->package.elements[1];
228234
result = acpi_nondev_subnode_extract(desc, NULL, link,
229235
list, parent);
@@ -396,6 +402,9 @@ static void acpi_untie_nondev_subnodes(struct acpi_device_data *data)
396402
struct acpi_data_node *dn;
397403

398404
list_for_each_entry(dn, &data->subnodes, sibling) {
405+
if (!dn->handle)
406+
continue;
407+
399408
acpi_detach_data(dn->handle, acpi_nondev_subnode_tag);
400409

401410
acpi_untie_nondev_subnodes(&dn->data);
@@ -410,6 +419,9 @@ static bool acpi_tie_nondev_subnodes(struct acpi_device_data *data)
410419
acpi_status status;
411420
bool ret;
412421

422+
if (!dn->handle)
423+
continue;
424+
413425
status = acpi_attach_data(dn->handle, acpi_nondev_subnode_tag, dn);
414426
if (ACPI_FAILURE(status) && status != AE_ALREADY_EXISTS) {
415427
acpi_handle_err(dn->handle, "Can't tag data node\n");

0 commit comments

Comments
 (0)