Skip to content

Commit 23583f7

Browse files
plbossartrafaeljw
authored andcommitted
ACPI / property: fix handling of data_nodes in acpi_get_next_subnode()
When the DSDT tables expose devices with subdevices and a set of hierarchical _DSD properties, the data returned by acpi_get_next_subnode() is incorrect, with the results suggesting a bad pointer assignment. The parser works fine with device_nodes or data_nodes, but not with a combination of the two. The problem is traced to an invalid pointer used when jumping from handling device_nodes to data nodes. The existing code looks for data nodes below the last subdevice found instead of the common root. Fix by forcing the acpi_device pointer to be derived from the same fwnode for the two types of subnodes. This same problem of handling device and data nodes was already fixed in a similar way by 'commit bf4703f ("ACPI / property: fix data node parsing in acpi_get_next_subnode()")' but broken later by 'commit 3405519 ("ACPI / property: Add fwnode_get_next_child_node()")', so this should probably go to linux-stable all the way to 4.12 Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 0fcc2bd commit 23583f7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/acpi/property.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,14 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
10321032
const struct acpi_data_node *data = to_acpi_data_node(fwnode);
10331033
struct acpi_data_node *dn;
10341034

1035+
/*
1036+
* We can have a combination of device and data nodes, e.g. with
1037+
* hierarchical _DSD properties. Make sure the adev pointer is
1038+
* restored before going through data nodes, otherwise we will
1039+
* be looking for data_nodes below the last device found instead
1040+
* of the common fwnode shared by device_nodes and data_nodes.
1041+
*/
1042+
adev = to_acpi_device_node(fwnode);
10351043
if (adev)
10361044
head = &adev->data.subnodes;
10371045
else if (data)

0 commit comments

Comments
 (0)