summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@stericsson.com>2011-01-05 00:44:32 +0100
committerChris Ball <cjb@laptop.org>2011-01-08 23:52:33 -0500
commite9b86841b372de01ae865080118e29159d8b7c39 (patch)
treec950489d3f41063fc0acc4b259ce4d4bae676d12 /drivers/mmc/core
parent2bd6a935555b06622fa7f47a9c411b8a7812e4dc (diff)
mmc: fix division by zero in MMC core
The card is not always clocked and the clock frequency zero is perfectly legal, thus this code in mmc_set_data_timeout() may cause a division by zero. It will be triggered more often if you're using software clock gating but can be triggered under other conditions too. Reported-by: Pierre Tardy <tardyp@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Reviewed-by: Chris Ball <cjb@laptop.org> Cc: <stable@kernel.org> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r--drivers/mmc/core/core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 4b1d8fb04e9..6625c057be0 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -299,8 +299,9 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
unsigned int timeout_us, limit_us;
timeout_us = data->timeout_ns / 1000;
- timeout_us += data->timeout_clks * 1000 /
- (mmc_host_clk_rate(card->host) / 1000);
+ if (mmc_host_clk_rate(card->host))
+ timeout_us += data->timeout_clks * 1000 /
+ (mmc_host_clk_rate(card->host) / 1000);
if (data->flags & MMC_DATA_WRITE)
/*