From: Mark Brown Date: Wed, 10 Jul 2013 14:05:40 +0000 (+0100) Subject: spi: More sanity checks for transfers X-Git-Tag: KARO-TX6-2014-07-10~190 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d507e111e3049e26bdf53611523a8d5eaf7679d1;p=karo-tx-linux.git spi: More sanity checks for transfers Check that transfers are non-empty and that there is a completion for them. Signed-off-by: Mark Brown Signed-off-by: Huang Shijie --- diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d4f9670b51bc..3ee46ffe90b4 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1843,6 +1843,11 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) if (list_empty(&message->transfers)) return -EINVAL; + 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