All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: bcm-qspi: check for valid cs before applying chip select
@ 2022-01-27 18:53 Kamal Dasu
  2022-01-27 18:59 ` Florian Fainelli
  2022-01-28 15:59 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Kamal Dasu @ 2022-01-27 18:53 UTC (permalink / raw)
  To: broonie, linux-spi, linux-kernel
  Cc: f.fainelli, bcm-kernel-feedback-list, Kamal Dasu

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>
---
 drivers/spi/spi-bcm-qspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c
index c9a769b8594b..86c76211b3d3 100644
--- a/drivers/spi/spi-bcm-qspi.c
+++ b/drivers/spi/spi-bcm-qspi.c
@@ -585,7 +585,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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: bcm-qspi: check for valid cs before applying chip select
  2022-01-27 18:53 [PATCH] spi: bcm-qspi: check for valid cs before applying chip select Kamal Dasu
@ 2022-01-27 18:59 ` Florian Fainelli
  2022-01-28 15:59 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2022-01-27 18:59 UTC (permalink / raw)
  To: Kamal Dasu, broonie, linux-spi, linux-kernel; +Cc: bcm-kernel-feedback-list



On 1/27/2022 10:53 AM, Kamal Dasu wrote:
> 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>

Thanks!
-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] spi: bcm-qspi: check for valid cs before applying chip select
  2022-01-27 18:53 [PATCH] spi: bcm-qspi: check for valid cs before applying chip select Kamal Dasu
  2022-01-27 18:59 ` Florian Fainelli
@ 2022-01-28 15:59 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-01-28 15:59 UTC (permalink / raw)
  To: Kamal Dasu, linux-kernel, linux-spi; +Cc: f.fainelli, bcm-kernel-feedback-list

On Thu, 27 Jan 2022 13:53:59 -0500, Kamal Dasu wrote:
> 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.
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-linus

Thanks!

[1/1] spi: bcm-qspi: check for valid cs before applying chip select
      commit: 2cbd27267ffe020af1442b95ec57f59a157ba85c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-28 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 18:53 [PATCH] spi: bcm-qspi: check for valid cs before applying chip select Kamal Dasu
2022-01-27 18:59 ` Florian Fainelli
2022-01-28 15:59 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.