linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v4.9 PATCH] spi: fsl-espi: avoid processing uninitalized data on error
@ 2016-10-25 20:57 Arnd Bergmann
  0 siblings, 0 replies; only message in thread
From: Arnd Bergmann @ 2016-10-25 20:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: Arnd Bergmann, stable, Heiner Kallweit, Nobuteru Hayashi,
	linux-spi, linux-kernel

When we get a spurious interrupt in fsl_espi_irq, we end up
processing four uninitalized bytes of data, as shown in this
warning message:

   drivers/spi/spi-fsl-espi.c: In function 'fsl_espi_irq':
   drivers/spi/spi-fsl-espi.c:462:4: warning: 'rx_data' may be used uninitialized in this function [-Wmaybe-uninitialized]

This adds another check so we skip the data in this case.

Fixes: 6319a68011b8 ("spi/fsl-espi: avoid infinite loops on fsl_espi_cpu_irq()")
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/spi/spi-fsl-espi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

This is a bugfix that we should get into v4.9. It conflicts with
a rework of that function that is currently scheduled in spi-next
for v4.10, but is also required there in some form.

I suppose we also want this backported to -stable, as we also get
the warning in older kernels, and the patch that introduced
the condition apparently address to fix the hardware problem
that would now lead to incorrect data instead of an infinite loop.

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 7451585..2c175b9 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -458,7 +458,7 @@ static void fsl_espi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
 
 		mspi->len -= rx_nr_bytes;
 
-		if (mspi->rx)
+		if (rx_nr_bytes && mspi->rx)
 			mspi->get_rx(rx_data, mspi);
 	}
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-25 20:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 20:57 [v4.9 PATCH] spi: fsl-espi: avoid processing uninitalized data on error Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).