ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value
PATCH 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.
--- 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 (fwnode, prop_name, &nr))continue ;if (val == nr)
Signature · 1 line
2.7.4
Hi Sakari,
You forgot "fwnode" => "child".
if (fwnode_property_read_u32(fwnode, prop_name, &nr)) => if (fwnode_property_read_u32(child, prop_name, &nr))
-Hyungwoo
-----Original Message-----
Quoted 34 lines
From: Sakari Ailus [mailto:[email protected]]
Sent: Tuesday, August 22, 2017 12:01 AM
To: [email protected]
Cc: Yang, Hyungwoo <[email protected]>; Westerberg, Mika <[email protected]>; [email protected]
Subject: [PATCH 1/1] ACPI: device property: Fix node lookup inacpi_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 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]>--- drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/property.c +1
-2@@ -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 (fwnode, prop_name, &nr))continue ;if (val == nr) --2.7.4
Quoted 8 lines · Hyungwoo
Hi Sakari,
You forgot "fwnode" => "child".
if (
fwnode_property_read_u32(fwnode, prop_name, &nr)) => if (fwnode_property_read_u32(child, prop_name, &nr))
Oops. I'll send v2...
Signature · 2 lines
Sakari Ailus [email protected]