[PATCH 1/7] spi: core: Validate Tx/Rx buffers for non-zero length transfer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reject transfer if both tx_buf and rx_buf are NULL for non-zero length transfer.
Add the checking in spi core so we can remove the same checking in various
drivers.

Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
---
 drivers/spi/spi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 26b331d..0a29d2a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1876,6 +1876,10 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 		if (xfer->len % w_size)
 			return -EINVAL;
 
+		/* non-zero length transfer must has tx_buf or rx_buf */
+		if (xfer->len && !xfer->tx_buf && !xfer->rx_buf)
+			return -EINVAL;
+
 		if (xfer->speed_hz && master->min_speed_hz &&
 		    xfer->speed_hz < master->min_speed_hz)
 			return -EINVAL;
-- 
1.8.3.2



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




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux