diff mbox

spi: img-spfi: Verify max spfi transfer length

Message ID 1425312406-14076-1-git-send-email-sifan.naeem@imgtec.com (mailing list archive)
State Accepted
Commit f165ed63370cfcc3a459cbd855822559f375a538
Headers show

Commit Message

Sifan Naeem March 2, 2015, 4:06 p.m. UTC
Maximum transfer length supported by SPFI is 65535, this is limited
by the number of bits available in SPFI TSize register to represent
the transfer size.
For transfer requests larger than the maximum supported the driver
will return an invalid argument error.

Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/spi/spi-img-spfi.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Mark Brown March 3, 2015, 2:26 p.m. UTC | #1
On Mon, Mar 02, 2015 at 04:06:46PM +0000, Sifan Naeem wrote:
> Maximum transfer length supported by SPFI is 65535, this is limited
> by the number of bits available in SPFI TSize register to represent
> the transfer size.
> For transfer requests larger than the maximum supported the driver
> will return an invalid argument error.

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index c01567d..e649bc7 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -459,6 +459,13 @@  static int img_spfi_transfer_one(struct spi_master *master,
 	unsigned long flags;
 	int ret;
 
+	if (xfer->len > SPFI_TRANSACTION_TSIZE_MASK) {
+		dev_err(spfi->dev,
+			"Transfer length (%d) is greater than the max supported (%d)",
+			xfer->len, SPFI_TRANSACTION_TSIZE_MASK);
+		return -EINVAL;
+	}
+
 	/*
 	 * Stop all DMA and reset the controller if the previous transaction
 	 * timed-out and never completed it's DMA.