Commit e9b86841 authored by Linus Walleij's avatar Linus Walleij Committed by Chris Ball

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: default avatarPierre Tardy <tardyp@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
Reviewed-by: default avatarChris Ball <cjb@laptop.org>
Cc: <stable@kernel.org>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 2bd6a935
...@@ -299,6 +299,7 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) ...@@ -299,6 +299,7 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
unsigned int timeout_us, limit_us; unsigned int timeout_us, limit_us;
timeout_us = data->timeout_ns / 1000; timeout_us = data->timeout_ns / 1000;
if (mmc_host_clk_rate(card->host))
timeout_us += data->timeout_clks * 1000 / timeout_us += data->timeout_clks * 1000 /
(mmc_host_clk_rate(card->host) / 1000); (mmc_host_clk_rate(card->host) / 1000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment