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: <20230613134146.418016-1-yann.gautier@foss.st.com>
Date:   Tue, 13 Jun 2023 15:41:46 +0200
From:   Yann Gautier <yann.gautier@...s.st.com>
To:     Ulf Hansson <ulf.hansson@...aro.org>, <linux-mmc@...r.kernel.org>
CC:     Russell King <linux@...linux.org.uk>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Christophe Kerello <christophe.kerello@...s.st.com>,
        Rob Herring <robh@...nel.org>,
        Xiang wangx <wangxiang@...rlc.com>,
        Yang Yingliang <yangyingliang@...wei.com>,
        <linux-kernel@...r.kernel.org>, Marek Vasut <marex@...x.de>,
        Linus Walleij <linus.walleij@...aro.org>,
        Dennis Zhou <dennis@...nel.org>,
        Yann Gautier <yann.gautier@...s.st.com>
Subject: [PATCH] mmc: mmci: stm32: fix max busy timeout calculation

From: Christophe Kerello <christophe.kerello@...s.st.com>

The way that the timeout is currently calculated could lead to a u64
timeout value in mmci_start_command(). This value is then cast in a u32
register that leads to mmc erase failed issue with some SD cards.

Fixes: 8266c585f489 ("mmc: mmci: add hardware busy timeout feature")
Signed-off-by: Yann Gautier <yann.gautier@...s.st.com>
Signed-off-by: Christophe Kerello <christophe.kerello@...s.st.com>
---
 drivers/mmc/host/mmci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f2b2e8b0574e8..696cbef3ff7de 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1735,7 +1735,8 @@ static void mmci_set_max_busy_timeout(struct mmc_host *mmc)
 		return;
 
 	if (host->variant->busy_timeout && mmc->actual_clock)
-		max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC);
+		max_busy_timeout = U32_MAX / DIV_ROUND_UP(mmc->actual_clock,
+							  MSEC_PER_SEC);
 
 	mmc->max_busy_timeout = max_busy_timeout;
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ