lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 11 Sep 2020 16:47:01 +0200
From:   Marco Felsch <m.felsch@...gutronix.de>
To:     tudor.ambarus@...rochip.com, miquel.raynal@...tlin.com,
        richard@....at, vigneshr@...com,
        sergei.shtylyov@...entembedded.com, boris.brezillon@...labora.com,
        michael@...le.cc, j.neuschaefer@....net
Cc:     linux-mtd@...ts.infradead.org, kernel@...gutronix.de,
        linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] mtd: spi-nor: sst: fix write support for SST_WRITE marked devices

The sst write support for devices using the special SST_WRITE routine
is broken since commit commit df5c21002cf4 ("mtd: spi-nor: use spi-mem
dirmap API") because the spi_nor_create_write_dirmap() function checks
SPINOR_OP_AAI_WP and sst_write_second. These checks are not valid during
probe. The check seems also to be broken since the "op->addr.nbytes = 0"
causes the devm_spi_mem_dirmap_create() function to return
PTR_ERR(-EINVAL) and the probe() function will fail.

It seems that the commit only copy'n'pasted the existing logic. Use the
correct SST_WRITE flag and return 0 to fix both issues.

Fixes: df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API")
Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
---
 drivers/mtd/spi-nor/core.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 65eff4ce6ab1..31869ac245a8 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3289,15 +3289,21 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
 	};
 	struct spi_mem_op *op = &info.op_tmpl;
 
+	/*
+	 * Most SST SPI-NOR's have a special write routine.which should so
+	 * dirmap.wdesc is not supported for these.
+	 */
+	if (nor->info->flags & SST_WRITE) {
+		nor->dirmap.wdesc = NULL;
+		return 0;
+	}
+
 	/* get transfer protocols. */
 	op->cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->write_proto);
 	op->addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto);
 	op->dummy.buswidth = op->addr.buswidth;
 	op->data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto);
 
-	if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second)
-		op->addr.nbytes = 0;
-
 	nor->dirmap.wdesc = devm_spi_mem_dirmap_create(nor->dev, nor->spimem,
 						       &info);
 	return PTR_ERR_OR_ZERO(nor->dirmap.wdesc);
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ