Skip to contentSkip to conversation

ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value

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

lore
Share & tools
lore
#0 lore raw

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.

Fixes 79389a83bc38 ("ACPI / property: Add support for remote endpoints")

---
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
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(child, prop_name, &nr))
 			continue;
 
 		if (val == nr)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 26 lines · Sakari Ailus

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")

---
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
index a65c09c..3963098 100644

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 -1
                        continue;
 
                if (val == nr)
--
#2 lore raw
Quoted 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 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")

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