Skip to content
Unverified Commit 5442dcaa authored by Chris Lesiak's avatar Chris Lesiak Committed by Mark Brown
Browse files

spi: Fix zero length xfer bug



This fixes a bug for messages containing both zero length and
unidirectional xfers.

The function spi_map_msg will allocate dummy tx and/or rx buffers
for use with unidirectional transfers when the hardware can only do
a bidirectional transfer.  That dummy buffer will be used in place
of a NULL buffer even when the xfer length is 0.

Then in the function __spi_map_msg, if he hardware can dma,
the zero length xfer will have spi_map_buf called on the dummy
buffer.

Eventually, __sg_alloc_table is called and returns -EINVAL
because nents == 0.

This fix prevents the error by not using the dummy buffer when
the xfer length is zero.

Signed-off-by: default avatarChris Lesiak <chris.lesiak@licor.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0e836c3b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment