diff mbox series

of: address: Fix parser address/size cells initialization

Message ID 20200731100248.26982-1-nsaenzjulienne@suse.de
State Not Applicable
Headers show
Series of: address: Fix parser address/size cells initialization | expand

Checks

Context Check Description
robh/checkpatch warning total: 0 errors, 1 warnings, 13 lines checked

Commit Message

Nicolas Saenz Julienne July 31, 2020, 10:02 a.m. UTC
bus->count_cells() parses cells starting from the node's parent. This is
not good enough for parser_init() which is generally parsing a bus node.

Revert to previous behavior using of_bus_n_*_cells().

Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/of/address.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Rob Herring July 31, 2020, 3:03 p.m. UTC | #1
On Fri, Jul 31, 2020 at 4:02 AM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> bus->count_cells() parses cells starting from the node's parent. This is
> not good enough for parser_init() which is generally parsing a bus node.
>
> Revert to previous behavior using of_bus_n_*_cells().
>
> Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> Reported-by: Nathan Chancellor <natechancellor@gmail.com>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>  drivers/of/address.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

We have a unit test for this code, does it fail? If not, adjusting it
to fail or adding a test case would be nice. Either way:

Acked-by: Rob Herring <robh@kernel.org>
Thomas Bogendoerfer July 31, 2020, 3:45 p.m. UTC | #2
On Fri, Jul 31, 2020 at 12:02:48PM +0200, Nicolas Saenz Julienne wrote:
> bus->count_cells() parses cells starting from the node's parent. This is
> not good enough for parser_init() which is generally parsing a bus node.
> 
> Revert to previous behavior using of_bus_n_*_cells().
> 
> Fixes: 2f96593ecc37 ("of_address: Add bus type match for pci ranges parser")
> Reported-by: Nathan Chancellor <natechancellor@gmail.com>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>  drivers/of/address.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

applied to mips-next.

Thomas.
diff mbox series

Patch

diff --git a/drivers/of/address.c b/drivers/of/address.c
index 275d764efc77..89822e191956 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -701,11 +701,11 @@  static int parser_init(struct of_pci_range_parser *parser,
 
 	parser->node = node;
 	parser->pna = of_n_addr_cells(node);
+	parser->na = of_bus_n_addr_cells(node);
+	parser->ns = of_bus_n_size_cells(node);
 	parser->dma = !strcmp(name, "dma-ranges");
 	parser->bus = of_match_bus(node);
 
-	parser->bus->count_cells(parser->node, &parser->na, &parser->ns);
-
 	parser->range = of_get_property(node, name, &rlen);
 	if (parser->range == NULL)
 		return -ENOENT;