Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9fc4851 authored by Kamal Dasu's avatar Kamal Dasu Committed by Greg Kroah-Hartman
Browse files

spi: bcm-qspi: check for valid cs before applying chip select



commit 2cbd27267ffe020af1442b95ec57f59a157ba85c upstream.

Apply only valid chip select value. This change fixes case where chip
select is set to initial value of '-1' during probe and  PM supend and
subsequent resume can try to use the value with undefined behaviour.
Also in case where gpio based chip select, the check in
bcm_qspi_chip_select() shall prevent undefined behaviour on resume.

Fixes: fa236a7e ("spi: bcm-qspi: Add Broadcom MSPI driver")
Signed-off-by: default avatarKamal Dasu <kdasu.kdev@gmail.com>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6e0498e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ static void bcm_qspi_chip_select(struct bcm_qspi *qspi, int cs)
	u32 rd = 0;
	u32 wr = 0;

	if (qspi->base[CHIP_SELECT]) {
	if (cs >= 0 && qspi->base[CHIP_SELECT]) {
		rd = bcm_qspi_read(qspi, CHIP_SELECT, 0);
		wr = (rd & ~0xff) | (1 << cs);
		if (rd == wr)