Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: ulpi: fix bus-node lookup

Fix bus-node lookup during registration, which ended up searching the whole
device tree depth-first starting at the parent (or grand parent) rather
than just matching on its children.

To make things worse, the parent (or grand-parent) node could end being
prematurely freed as well.

Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT")
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Reported-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: stable <stable@vger.kernel.org> # 4.10
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
33c309eb 446f666d

+2 -2
+2 -2
drivers/usb/common/ulpi.c
··· 180 180 /* Find a ulpi bus underneath the parent or the grandparent */ 181 181 parent = ulpi->dev.parent; 182 182 if (parent->of_node) 183 - np = of_find_node_by_name(parent->of_node, "ulpi"); 183 + np = of_get_child_by_name(parent->of_node, "ulpi"); 184 184 else if (parent->parent && parent->parent->of_node) 185 - np = of_find_node_by_name(parent->parent->of_node, "ulpi"); 185 + np = of_get_child_by_name(parent->parent->of_node, "ulpi"); 186 186 if (!np) 187 187 return 0; 188 188