Skip to content

Commit 3ca7ddd

Browse files
Vladimir Zapolskiygregkh
authored andcommitted
spi: sh-msiof: Fix bit field overflow writes to TSCR/RSCR
[ Upstream commit 10b4640 ] 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: 65d5665 ("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>
1 parent b3ccb8a commit 3ca7ddd

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎drivers/spi/spi-sh-msiof.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
277277
}
278278

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

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

0 commit comments

Comments
 (0)