In commit 4c2357f57dd5 ("mmc: dw_mmc: Fix the CTO timeout calculation")
have been made changes which can cause multiply overflow for 32-bit systems.
The value of cto_ms is lower the drto_ms, but nevertheless overflow can occur.
Lets cast this multiply to u64 type which prevents overflow.

Signed-off-by: Evgeniy Didin <evgeniy.di...@synopsys.com>

CC: Alexey Brodkin <abrod...@synopsys.com>
CC: Eugeniy Paltsev <palt...@synopsys.com>
CC: Douglas Anderson <diand...@chromium.org>
CC: Ulf Hansson <ulf.hans...@linaro.org>
CC: linux-kernel@vger.kernel.org
CC: linux-snps-...@lists.infradead.org
Cc: <sta...@vger.kernel.org> #  4c2357f57dd5 mmc: dw_mmc: Fix the CTO timeout 
calculation
---
 drivers/mmc/host/dw_mmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 194159219b32..775fb3ae1443 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -409,7 +409,8 @@ static inline void dw_mci_set_cto(struct dw_mci *host)
        cto_div = (mci_readl(host, CLKDIV) & 0xff) * 2;
        if (cto_div == 0)
                cto_div = 1;
-       cto_ms = DIV_ROUND_UP(MSEC_PER_SEC * cto_clks * cto_div, host->bus_hz);
+
+       cto_ms = DIV_ROUND_UP((u64)MSEC_PER_SEC * cto_clks * cto_div, 
host->bus_hz);
 
        /* add a bit spare time */
        cto_ms += 10;
-- 
2.11.0

Reply via email to