Re: [PATCH] spi: fix zero-length scatterlist entries for vmalloc buffers

From: Mark Brown

Date: Mon Oct 26 2026 - 15:02:57 EST


> Fix the entry count to match the way the loop consumes the buffer, and skip
> zero length transfers entirely.

> + if (!len) {
> + /*
> + * Zero-length transfers need no DMA mapping. Leave an empty
> + * table behind so spi_unmap_buf_attrs() sees orig_nents == 0.
> + */
> + memset(sgt, 0, sizeof(*sgt));
> + return 0;
> + }

This isn't needed - the rest of the patch changes the call to
sg_alloc_table() so it will fail, and returning success will confuse
things downstream. The KUnit tests should also be failing with this,
they rely on a zero length transfer to force -EINVAL and get into error
handling.

--
Mark Brown <broonie@xxxxxxxxxx>