lkml.org 
[lkml]   [2018]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 013/189] spi: sh-msiof: Fix bit field overflow writes to TSCR/RSCR
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

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

    From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>

    [ Upstream commit 10b4640833e95eeacaef8060bc1b35e636df3218 ]

    The change fixes a bit field overflow which allows to write to higher
    bits while calculating SPI transfer clock and setting BRPS and BRDV
    bit fields, the problem is reproduced if 'parent_rate' to 'spi_hz'
    ratio is greater than 1024, for instance

    p->min_div = 2,
    MSO rate = 33333333,
    SPI device rate = 10000

    results in

    k = 5, i.e. BRDV = 0b100 or 1/32 prescaler output,
    BRPS = 105,
    TSCR value = 0x6804, thus MSSEL and MSIMM bit fields are non-zero.

    Fixes: 65d5665bb260 ("spi: sh-msiof: Update calculation of frequency dividing")
    Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/spi/spi-sh-msiof.c | 1 +
    1 file changed, 1 insertion(+)

    --- a/drivers/spi/spi-sh-msiof.c
    +++ b/drivers/spi/spi-sh-msiof.c
    @@ -277,6 +277,7 @@ static void sh_msiof_spi_set_clk_regs(st
    }

    k = min_t(int, k, ARRAY_SIZE(sh_msiof_spi_div_table) - 1);
    + brps = min_t(int, brps, 32);

    scr = sh_msiof_spi_div_table[k].brdv | SCR_BRPS(brps);
    sh_msiof_write(p, TSCR, scr);

    \
     
     \ /
      Last update: 2018-06-18 11:14    [W:4.133 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site