diff mbox

spi: fsl-espi: avoid processing uninitalized data on error

Message ID b5d3b5f3-034e-28c4-e616-69de4bf7cb8f@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Heiner Kallweit Oct. 27, 2016, 5:55 a.m. UTC
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.

A functionally identical patch was submitted for stable
already, however due to a merge conflict a separate patch
is needed for next.

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

Comments

Mark Brown Oct. 27, 2016, 10:14 a.m. UTC | #1
On Thu, Oct 27, 2016 at 07:55:30AM +0200, Heiner Kallweit wrote:
> 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:

This doesn't apply against current code, please check and resend.
Heiner Kallweit Oct. 27, 2016, 6:11 p.m. UTC | #2
Am 27.10.2016 um 12:14 schrieb Mark Brown:
> On Thu, Oct 27, 2016 at 07:55:30AM +0200, Heiner Kallweit wrote:
>> 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:
> 
> This doesn't apply against current code, please check and resend.
> 
OK, I'll provide an updated one. I thought it was intended to
replace Arnd's patch for next.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index eea5123..4e8a99d 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -455,7 +455,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) {
 			*(u32 *)mspi->rx = rx_data;
 			mspi->rx += 4;
 		}