lkml.org 
[lkml]   [2015]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.0 082/148] mmc: atmel-mci: fix bad variable type for clkdiv
    Date
    4.0-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Ludovic Desroches <ludovic.desroches@atmel.com>

    commit 60c8f783a18feb95ad967c87e9660caf09fb4700 upstream.

    clkdiv is declared as an u32 but it can be set to a negative value
    causing a huge divisor value. Change its type to int to avoid this case.

    Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/mmc/host/atmel-mci.c | 9 +++++++--
    1 file changed, 7 insertions(+), 2 deletions(-)

    --- a/drivers/mmc/host/atmel-mci.c
    +++ b/drivers/mmc/host/atmel-mci.c
    @@ -1304,7 +1304,7 @@ static void atmci_set_ios(struct mmc_hos

    if (ios->clock) {
    unsigned int clock_min = ~0U;
    - u32 clkdiv;
    + int clkdiv;

    spin_lock_bh(&host->lock);
    if (!host->mode_reg) {
    @@ -1328,7 +1328,12 @@ static void atmci_set_ios(struct mmc_hos
    /* Calculate clock divider */
    if (host->caps.has_odd_clk_div) {
    clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2;
    - if (clkdiv > 511) {
    + if (clkdiv < 0) {
    + dev_warn(&mmc->class_dev,
    + "clock %u too fast; using %lu\n",
    + clock_min, host->bus_hz / 2);
    + clkdiv = 0;
    + } else if (clkdiv > 511) {
    dev_warn(&mmc->class_dev,
    "clock %u too slow; using %lu\n",
    clock_min, host->bus_hz / (511 + 2));



    \
     
     \ /
      Last update: 2015-06-03 15:21    [W:4.148 / U:0.368 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site