summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamal Dasu <kdasu.kdev@gmail.com>2022-01-27 13:53:59 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-08 18:23:15 +0100
commit6a07d4a3863e2426168c3236a37ba1c232d9cd9f (patch)
treecaebcb22123bb26d408a00dbb426674150b0597c
parentbd2a6021b8778bf671a2f9739241543398a7c853 (diff)
downloadlinux-stable-6a07d4a3863e2426168c3236a37ba1c232d9cd9f.tar.gz
linux-stable-6a07d4a3863e2426168c3236a37ba1c232d9cd9f.tar.bz2
linux-stable-6a07d4a3863e2426168c3236a37ba1c232d9cd9f.zip
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: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/spi/spi-bcm-qspi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c
index b2fd7a369196..82c24c85f45b 100644
--- a/drivers/spi/spi-bcm-qspi.c
+++ b/drivers/spi/spi-bcm-qspi.c
@@ -520,7 +520,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)