Skip to contentSkip to conversation

ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value

PATCH Superseded Sakari Ailus 2 participants 3 messages Aug 22, 2017 ACPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Fixes 79389a83bc38 ("ACPI / property: Add support for remote endpoints")
---
 drivers/acpi/property.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/property.c +1 -1
index a65c09c..3963098 100644
@@ -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
#1 lore raw

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 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.

Fixes 79389a83bc38 ("ACPI / property: Add support for remote endpoints")
---
 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

#2 lore raw
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]