mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 22:54:05 +08:00
spi: sh-msiof: Fix bit field overflow writes to TSCR/RSCR
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: 65d5665bb2
("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>
This commit is contained in:
parent
af82800cd2
commit
10b4640833
@ -283,6 +283,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user