Skip to content

Commit

Permalink
mmc: fix division by zero in MMC core
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Walleij authored and Chris Ball committed Jan 9, 2011
1 parent 2bd6a93 commit e9b8684
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
/*
Expand Down

0 comments on commit e9b8684

Please sign in to comment.