mmc: fix division by zero in MMC core
[firefly-linux-kernel-4.4.55.git] / drivers / mmc / core / core.c
index 4b1d8fb04e9b30569579be2875777deae2e5a0ff..6625c057be05cf5a585d690b0d1d921cd938709b 100644 (file)
@@ -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)
                        /*