All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Ball <cjb@laptop.org>
To: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-mmc@vger.kernel.org, Pierre Tardy <tardyp@gmail.com>
Subject: Re: [PATCH] mmc: fix division by zero in MMC core
Date: Wed, 5 Jan 2011 21:55:46 +0000	[thread overview]
Message-ID: <20110105215546.GK9198@void.printf.net> (raw)
In-Reply-To: <1294184672-31644-1-git-send-email-linus.walleij@stericsson.com>

Hi Linus,

On Wed, Jan 05, 2011 at 12:44:32AM +0100, Linus Walleij wrote:
> 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)
>  			/*

Thanks, pushed to mmc-next for .38.  I'll add a stable tag.  Looks like
the potential for the divide-by-zero has always existed in the tree.

-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

      reply	other threads:[~2011-01-05 21:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-04 23:44 [PATCH] mmc: fix division by zero in MMC core Linus Walleij
2011-01-05 21:55 ` Chris Ball [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110105215546.GK9198@void.printf.net \
    --to=cjb@laptop.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=tardyp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.