Skip to content

Commit 9b22c17

Browse files
committed
of: Check 'of_node_reused' flag on of_match_device()
Commit 0f153a1 ("usb: chipidea: Set the DT node on the child device") caused the child device to match on the parent driver instead of the child's driver since the child's DT node pointer matched. The worst case result is a loop of the parent driver probing another instance and creating yet another child device eventually exhausting the stack. If the child driver happens to match first, then everything works fine. A device sharing the DT node should never do DT based driver matching, so let's simply check of_node_reused in of_match_device() to prevent that. Fixes: 0f153a1 ("usb: chipidea: Set the DT node on the child device") Link: https://lore.kernel.org/all/20220114105620.GK18506@ediswmail.ad.cirrus.com/ Reported-by: Charles Keepax <ckeepax@opensource.cirrus.com> Cc: Frank Rowand <frowand.list@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Tony Lindgren <tony@atomide.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Peter Chen <peter.chen@nxp.com> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20220118173404.1891800-1-robh@kernel.org
1 parent 2ca42c3 commit 9b22c17

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/of/device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
const struct of_device_id *of_match_device(const struct of_device_id *matches,
2929
const struct device *dev)
3030
{
31-
if ((!matches) || (!dev->of_node))
31+
if (!matches || !dev->of_node || dev->of_node_reused)
3232
return NULL;
3333
return of_match_node(matches, dev->of_node);
3434
}

0 commit comments

Comments
 (0)