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>] [day] [month] [year] [list]
Message-Id: <20250122065150.1352906-1-arnd@kernel.org>
Date: Wed, 22 Jan 2025 07:51:36 +0100
From: Arnd Bergmann <arnd@...nel.org>
To: Laxman Dewangan <ldewangan@...dia.com>,
	Jon Hunter <jonathanh@...dia.com>,
	Vinod Koul <vkoul@...nel.org>,
	Thierry Reding <thierry.reding@...il.com>,
	Mohan Kumar D <mkumard@...dia.com>
Cc: Arnd Bergmann <arnd@...db.de>,
	Uwe Kleine-König <u.kleine-koenig@...libre.com>,
	dmaengine@...r.kernel.org,
	linux-tegra@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] dmaengine: tegra210: avoid broken division

From: Arnd Bergmann <arnd@...db.de>

When build testing on 32-bit targets with 64-bit resource_size_t,
the new probe logic causes a link failure:

arm-linux-gnueabi-ld: drivers/dma/tegra210-adma.o: in function `tegra_adma_probe':
tegra210-adma.c:(.text+0x122c): undefined reference to `__aeabi_uldivmod'

In addition, it seems that the same division can trap when running
on tegra210, which sets .ch_base_offset=0.

Avoid both using the div_u64() helper and an added zero-check.

Fixes: 68811c928f88 ("dmaengine: tegra210-adma: Support channel page")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
 drivers/dma/tegra210-adma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index d80a60de0160..fd339f10151c 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -913,8 +913,9 @@ static int tegra_adma_probe(struct platform_device *pdev)
 			return PTR_ERR(tdma->ch_base_addr);
 
 		res_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "global");
-		if (res_base) {
-			page_no = (res_page->start - res_base->start) / cdata->ch_base_offset;
+		if (res_base && cdata->ch_base_offset) {
+			page_no = div_u64(res_page->start - res_base->start,
+					  cdata->ch_base_offset);
 			if (page_no <= 0)
 				return -EINVAL;
 			tdma->ch_page_no = page_no - 1;
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ