Skip to content

Commit

Permalink
spi: img-spfi: Verify max spfi transfer length
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Sifan Naeem authored and Mark Brown committed Mar 3, 2015
1 parent c517d83 commit f165ed6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/spi/spi-img-spfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f165ed6

Please sign in to comment.