archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: Check 'of_node_reused' flag on of_match_device()
@ 2022-01-18 17:34 Rob Herring
  2022-01-20 17:31 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2022-01-18 17:34 UTC (permalink / raw)
  To: Frank Rowand, Peter Chen, Greg Kroah-Hartman
  Cc: Charles Keepax, Arnd Bergmann, Tony Lindgren, Peter Chen,
	devicetree, linux-kernel

Commit 0f153a1b8193 ("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

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

Fixes: 0f153a1b8193 ("usb: chipidea: Set the DT node on the child device")
Reported-by: Charles Keepax <>
Cc: Frank Rowand <>
Cc: Arnd Bergmann <>
Cc: Tony Lindgren <>
Cc: Greg Kroah-Hartman <>
Cc: Peter Chen <>
Tested-by: Charles Keepax <>
Signed-off-by: Rob Herring <>
 drivers/of/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index b0800c260f64..874f031442dc 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -28,7 +28,7 @@
 const struct of_device_id *of_match_device(const struct of_device_id *matches,
 					   const struct device *dev)
-	if ((!matches) || (!dev->of_node))
+	if (!matches || !dev->of_node || dev->of_node_reused)
 		return NULL;
 	return of_match_node(matches, dev->of_node);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-20 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 17:34 [PATCH] of: Check 'of_node_reused' flag on of_match_device() Rob Herring
2022-01-20 17:31 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).