ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value
PATCH v2 1/1 ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value
acpi_graph_get_child_prop_value() is intended to find a child node with a certain property value pair. The check
if (!fwnode_property_read_u32(fwnode, prop_name, &nr)) continue;
is faulty: fwnode_property_read_u32() returns zero on success, not on failure, leading to comparing values only if the searched property was not found.
---
since v1:
- fwnode_rpoperty_read_u32( fwnode -> child )
drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/property.c +1 -1
@@ -1052,7 +1052,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(fwnode_for_each_child_node (fwnode, child) {u32 nr; -if (!fwnode_property_read_u32 (fwnode, prop_name, &nr)) +if (fwnode_property_read_u32 (child, prop_name, &nr))continue ;if (val == nr)
Signature · 1 line
2.7.4
Rafael J. Wysocki
maintainerQuoted 26 lines · Sakari Ailus
acpi_graph_get_child_prop_value()is intended to find a child node with a certain property value pair. The checkif (!fwnode_property_read_u32(fwnode, prop_name, &nr)) continue;is faulty:
fwnode_property_read_u32()returns zero on success, not on failure, leading to comparing values only if the searched property was not found.Fixes 79389a83bc38 ("ACPI / property: Add support for remote endpoints")Reported-by Hyungwoo Yang <[email protected]>Signed-off-by Sakari Ailus <[email protected]>---
since v1:-
fwnode_rpoperty_read_u32( fwnode -> child )drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/property.c +0
-0
drivers/acpi/property.c static struct fwnode_handle *acpi_graph_get_child_prop_value( · line 1055
Quoted 5 lines
drivers/acpi/property.c +1
-1@@ -1052,7 +1052,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(fwnode_for_each_child_node (fwnode, child) {u32 nr; -if (!fwnode_property_read_u32 (fwnode, prop_name, &nr)) +if (fwnode_property_read_u32 (child, prop_name, &nr))
OK, but it looks like there are two bugs in it (the zero vs nonzero return value and the first arg), but the changelog only mentions one of them.
Quoted 4 lines
drivers/acpi/property.c +0
-1continue ;if (val == nr) --
Rafael J. Wysocki
maintainerQuoted 31 lines · Rafael J. Wysocki
Quoted 29 lines · Sakari Ailus
acpi_graph_get_child_prop_value()is intended to find a child node with a certain property value pair. The checkif (!fwnode_property_read_u32(fwnode, prop_name, &nr)) continue;is faulty:
fwnode_property_read_u32()returns zero on success, not on failure, leading to comparing values only if the searched property was not found.Fixes 79389a83bc38 ("ACPI / property: Add support for remote endpoints")Reported-by Hyungwoo Yang <[email protected]>Signed-off-by Sakari Ailus <[email protected]>---
since v1:-
fwnode_rpoperty_read_u32( fwnode -> child )drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/property.c +0
-0@@ -1052,7 +1052,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(fwnode_for_each_child_node (fwnode, child) {u32 nr;
Quoted 6 lines
drivers/acpi/property.c static struct fwnode_handle *acpi_graph_get_child_prop_value( · line 1055
Quoted 2 lines
drivers/acpi/property.c +1
-1-if (!fwnode_property_read_u32 (fwnode, prop_name, &nr)) +if (fwnode_property_read_u32 (child, prop_name, &nr))OK, but it looks like there are two bugs in it (the zero vs nonzero return value and the first arg), but the changelog only mentions one of them.
But since this is a fix for a change that went in during the 4.12 cycle, I've added the missing information to the changelog and applied the patch.
Thanks,
Rafael