* [PATCH 1/1] ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value
@ 2017-08-22 7:01 Sakari Ailus
2017-08-22 17:47 ` Yang, Hyungwoo
0 siblings, 1 reply; 3+ messages in thread
From: Sakari Ailus @ 2017-08-22 7:01 UTC (permalink / raw)
To: linux-acpi; +Cc: hyungwoo.yang, mika.westerberg, rafael
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")
Reported-by: Hyungwoo Yang <hyungwoo.yang@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/acpi/property.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index a65c09c..3963098 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH 1/1] ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value
2017-08-22 7:01 [PATCH 1/1] ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value Sakari Ailus
@ 2017-08-22 17:47 ` Yang, Hyungwoo
2017-08-22 20:41 ` Sakari Ailus
0 siblings, 1 reply; 3+ messages in thread
From: Yang, Hyungwoo @ 2017-08-22 17:47 UTC (permalink / raw)
To: Sakari Ailus, linux-acpi@vger.kernel.org
Cc: Westerberg, Mika, rafael@kernel.org
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-----
> From: Sakari Ailus [mailto:sakari.ailus@linux.intel.com]
> Sent: Tuesday, August 22, 2017 12:01 AM
> To: linux-acpi@vger.kernel.org
> Cc: Yang, Hyungwoo <hyungwoo.yang@intel.com>; Westerberg, Mika <mika.westerberg@intel.com>; rafael@kernel.org
> 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")
> Reported-by: Hyungwoo Yang <hyungwoo.yang@intel.com>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> drivers/acpi/property.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index a65c09c..3963098 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value
2017-08-22 17:47 ` Yang, Hyungwoo
@ 2017-08-22 20:41 ` Sakari Ailus
0 siblings, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2017-08-22 20:41 UTC (permalink / raw)
To: Yang, Hyungwoo, linux-acpi@vger.kernel.org
Cc: Westerberg, Mika, rafael@kernel.org
Yang, Hyungwoo wrote:
>
> 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...
--
Sakari Ailus
sakari.ailus@linux.intel.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-22 20:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 7:01 [PATCH 1/1] ACPI: device property: Fix node lookup in acpi_graph_get_child_prop_value Sakari Ailus
2017-08-22 17:47 ` Yang, Hyungwoo
2017-08-22 20:41 ` Sakari Ailus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox