spi: airoha: buffer must be 0xff-ed before writing

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>
This commit is contained in:
Mikhail Kshevetskiy
2025-11-09 10:06:52 +03:00
committed by Michael Trimarchi
parent 531e1fe34b
commit 2996c2a7a8

View 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)