spi: More sanity checks for transfers
authorMark Brown <broonie@linaro.org>
Wed, 10 Jul 2013 14:05:40 +0000 (15:05 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 15 Jul 2013 10:34:51 +0000 (11:34 +0100)
Check that transfers are non-empty and that there is a completion for
them.

Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi.c

index a52f16685d6aa40b18c642322ce7e9af7c6c9f48..c2899161ccacf8a6ecaebd807ef2613349104cae 100644 (file)
@@ -1351,6 +1351,11 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
        struct spi_master *master = spi->master;
        struct spi_transfer *xfer;
 
+       if (list_empty(&message->transfers))
+               return -EINVAL;
+       if (!message->complete)
+               return -EINVAL;
+
        /* Half-duplex links include original MicroWire, and ones with
         * only one data pin like SPI_3WIRE (switches direction) or where
         * either MOSI or MISO is missing.  They can also be caused by