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: <20250727180100.15961-1-kjw1627@gmail.com>
Date: Mon, 28 Jul 2025 02:01:00 +0800
From: Joonwon Kang <kjw1627@...il.com>
To: robh@...nel.org,
	saravanak@...gle.com
Cc: nsaenzjulienne@...e.de,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Joonwon Kang <kjw1627@...il.com>
Subject: [PATCH] of: address: Fix bug to get the highest cpu address of subtrees for dma

The function of_dma_get_max_cpu_address() for a device node should choose
the highest cpu address among the ones that subtree nodes can access.
However, there was a bug of choosing the lowest cpu address and this
commit is to fix it.

Signed-off-by: Joonwon Kang <kjw1627@...il.com>
---
 drivers/of/address.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index f0f8f0dd191c..5e984e0d372b 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -969,6 +969,7 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
 {
 	phys_addr_t max_cpu_addr = PHYS_ADDR_MAX;
 	struct of_range_parser parser;
+	phys_addr_t max_subtree_max_addr = PHYS_ADDR_MAX;
 	phys_addr_t subtree_max_addr;
 	struct device_node *child;
 	struct of_range range;
@@ -992,10 +993,17 @@ phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
 
 	for_each_available_child_of_node(np, child) {
 		subtree_max_addr = of_dma_get_max_cpu_address(child);
-		if (max_cpu_addr > subtree_max_addr)
-			max_cpu_addr = subtree_max_addr;
+		if (subtree_max_addr == PHYS_ADDR_MAX)
+			continue;
+
+		if (max_subtree_max_addr == PHYS_ADDR_MAX)
+			max_subtree_max_addr = subtree_max_addr;
+		else
+			max_subtree_max_addr = max(max_subtree_max_addr, subtree_max_addr);
 	}
 
+	max_cpu_addr = min(max_cpu_addr, max_subtree_max_addr);
+
 	return max_cpu_addr;
 }
 
-- 
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ