]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: airoha: buffer must be 0xff-ed before writing
authorMikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Sun, 12 Oct 2025 12:17:04 +0000 (15:17 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 17 Oct 2025 12:30:53 +0000 (13:30 +0100)
During writing, the entire flash page (including OOB) will be updated
with the values from the temporary buffer, so we need to fill the
untouched areas of the buffer with 0xff value to prevent accidental
data overwriting.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patch.msgid.link/20251012121707.2296160-14-mikhail.kshevetskiy@iopsys.eu
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-airoha-snfi.c

index 437ab6745b1a5806637df324e7e2e5b3dbef21c5..8408aee9c06ed27fa1cbeebd05a7d36c2d6a94fc 100644 (file)
@@ -776,7 +776,11 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem_dirmap_desc *desc,
                return -EOPNOTSUPP;
        }
 
+       if (offs > 0)
+               memset(txrx_buf, 0xff, offs);
        memcpy(txrx_buf + offs, buf, len);
+       if (bytes > offs + len)
+               memset(txrx_buf + offs + len, 0xff, bytes - offs - len);
 
        err = airoha_snand_set_mode(as_ctrl, SPI_MODE_DMA);
        if (err < 0)