summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRavikumar Kattekola <rk@ti.com>2017-01-30 15:41:58 +0530
committerBen Hutchings <ben@decadent.org.uk>2017-06-05 21:17:07 +0100
commitf9b8eb52c48b3e4582ab62ddea0191ef03e49ca4 (patch)
tree62b67618658136454ac0cd9a78d8007f094cc656 /drivers
parent0b95c2aa96ac14171f2f886cad040018f6a4bf8f (diff)
downloadlinux-stable-f9b8eb52c48b3e4582ab62ddea0191ef03e49ca4.tar.gz
linux-stable-f9b8eb52c48b3e4582ab62ddea0191ef03e49ca4.tar.bz2
linux-stable-f9b8eb52c48b3e4582ab62ddea0191ef03e49ca4.zip
mmc: host: omap_hsmmc: avoid possible overflow of timeout value
commit a53210f56d7f3f75d1edc1b3a069ddb87b72a919 upstream. Fixes: a45c6cb81647 ("[ARM] 5369/1: omap mmc: Add new omap hsmmc controller for 2430 and 34xx, v3") when using really large timeout (up to 4*60*1000 ms for bkops) there is a possibility of data overflow using unsigned int so use 64 bit unsigned long long. Signed-off-by: Ravikumar Kattekola <rk@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> [bwh: Backported to 3.16: drop change in omap_hsmmc_prepare_data()] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/host/omap_hsmmc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index d4368603e67a..a0a02a8a572e 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1393,10 +1393,11 @@ static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
}
static void set_data_timeout(struct omap_hsmmc_host *host,
- unsigned int timeout_ns,
+ unsigned long long timeout_ns,
unsigned int timeout_clks)
{
- unsigned int timeout, cycle_ns;
+ unsigned long long timeout = timeout_ns;
+ unsigned int cycle_ns;
uint32_t reg, clkd, dto = 0;
reg = OMAP_HSMMC_READ(host->base, SYSCTL);
@@ -1405,7 +1406,7 @@ static void set_data_timeout(struct omap_hsmmc_host *host,
clkd = 1;
cycle_ns = 1000000000 / (host->clk_rate / clkd);
- timeout = timeout_ns / cycle_ns;
+ do_div(timeout, cycle_ns);
timeout += timeout_clks;
if (timeout) {
while ((timeout & 0x80000000) == 0) {