spi: airoha: buffer must be 0xff-ed before writing
authorMikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Sun, 9 Nov 2025 07:06:52 +0000 (10:06 +0300)
committerMichael Trimarchi <michael@amarulasolutions.com>
Tue, 18 Nov 2025 19:07:41 +0000 (20:07 +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>
drivers/spi/airoha_snfi_spi.c

index 6538106..23c4507 100644 (file)
@@ -819,7 +819,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(priv, SPI_MODE_DMA);
        if (err < 0)