lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241230120315.2490-1-gordoste@iinet.net.au>
Date: Mon, 30 Dec 2024 23:03:14 +1100
From: Stephen Gordon <gordoste@...et.net.au>
To: Rob Herring <robh@...nel.org>,
	Saravana Kannan <saravanak@...gle.com>
Cc: Stephen Gordon <gordoste@...et.net.au>,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] of: dynamic: Avoid reversing sibling order

Current implementation inserts nodes at the head of the list, resulting
in sibling order being reversed from the .dts file. Some drivers care
about the order and do not work properly. These changes add nodes at the
end of the list instead, preversing sibling order.

Signed-off-by: Stephen Gordon <gordoste@...et.net.au>
---

I ran across this issue using the ASoC audio_graph_card2 driver. Prior
to the fix, I needed to reverse sibling order in the .dts to make things
work. After the fix, it all works as expected.

Also, I noticed that drivers/of/fdt.c line 325-330 fix the same problem
for flattened device trees.


 drivers/of/dynamic.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 0aba760f7577..57bea2d4af30 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -222,8 +222,15 @@ static void __of_attach_node(struct device_node *np)
 	}
 
 	np->child = NULL;
-	np->sibling = np->parent->child;
-	np->parent->child = np;
+	np->sibling = NULL;
+	struct device_node *last_child = np->parent->child;
+	if (!last_child)
+		np->parent->child = np;
+	else {
+		while (last_child->sibling)
+			last_child = last_child->sibling;
+		last_child->sibling = np;
+	}
 	of_node_clear_flag(np, OF_DETACHED);
 	np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE;
 
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ