[PATCH 4/4] mtd: spi-nor: spansion: make sure op does not contain garbage (2)
Tudor Ambarus
tudor.ambarus at linaro.org
Mon Jul 17 09:36:00 PDT 2023
Initialise local struct spi_mem_op with all zeros at declaration,
or by memset before the second use, in order to avoid using garbage
data for fields that are not explicitly set afterwards.
Fixes: b6b23833fc42 ("mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups")
Cc: stable at vger.kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus at linaro.org>
---
drivers/mtd/spi-nor/spansion.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
index c03445e46d56..7485b708158f 100644
--- a/drivers/mtd/spi-nor/spansion.c
+++ b/drivers/mtd/spi-nor/spansion.c
@@ -220,7 +220,7 @@ static int cypress_nor_octal_dtr_dis(struct spi_nor *nor)
static int cypress_nor_quad_enable_volatile_reg(struct spi_nor *nor, u64 addr)
{
- struct spi_mem_op op;
+ struct spi_mem_op op = {};
u8 addr_mode_nbytes = nor->params->addr_mode_nbytes;
u8 cfr1v_written;
int ret;
@@ -237,6 +237,7 @@ static int cypress_nor_quad_enable_volatile_reg(struct spi_nor *nor, u64 addr)
return 0;
/* Update the Quad Enable bit. */
+ memset(&op, 0, sizeof(op));
nor->bouncebuf[0] |= SPINOR_REG_CYPRESS_CFR1_QUAD_EN;
op = (struct spi_mem_op)
CYPRESS_NOR_WR_ANY_REG_OP(addr_mode_nbytes, addr, 1,
@@ -248,6 +249,7 @@ static int cypress_nor_quad_enable_volatile_reg(struct spi_nor *nor, u64 addr)
cfr1v_written = nor->bouncebuf[0];
/* Read back and check it. */
+ memset(&op, 0, sizeof(op));
op = (struct spi_mem_op)
CYPRESS_NOR_RD_ANY_REG_OP(addr_mode_nbytes, addr, 0,
nor->bouncebuf);
--
2.34.1
More information about the linux-mtd
mailing list