public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: fix division by zero in MMC core
@ 2011-01-04 23:44 Linus Walleij
  2011-01-05 21:55 ` Chris Ball
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2011-01-04 23:44 UTC (permalink / raw)
  To: linux-mmc, Chris Ball; +Cc: Pierre Tardy, Linus Walleij

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>
---
 drivers/mmc/core/core.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 97e0624..ef4f7f8 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)
 			/*
-- 
1.7.3.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-05 21:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-04 23:44 [PATCH] mmc: fix division by zero in MMC core Linus Walleij
2011-01-05 21:55 ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox