From: Linus Walleij Date: Tue, 4 Jan 2011 23:44:32 +0000 (+0100) Subject: mmc: fix division by zero in MMC core X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e9b8684;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Linus Walleij Reviewed-by: Chris Ball Cc: Signed-off-by: Chris Ball --- diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 4b1d8fb04e9b..6625c057be05 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) /*