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>
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>
This commit is contained in:
Mikhail Kshevetskiy 2025-10-12 15:17:04 +03:00 committed by Mark Brown
parent 902c0ea18a
commit 0743acf746
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 4 additions and 0 deletions

View File

@ -776,7 +776,11 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem_dirmap_desc *desc,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (offs > 0)
memset(txrx_buf, 0xff, offs);
memcpy(txrx_buf + offs, buf, len); 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); err = airoha_snand_set_mode(as_ctrl, SPI_MODE_DMA);
if (err < 0) if (err < 0)