All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pratyush Yadav" <pratyush@kernel.org>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	"Michael Walle" <mwalle@kernel.org>
Cc: "Steam Lin" <STLin2@winbond.com>,
	linux-kernel@vger.kernel.org,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH v2 07/17] mtd: spi-nor: Fix WRSR with ODTR chips
Date: Sun, 04 Oct 2026 21:43:23 +0000	[thread overview]
Message-ID: <20261004214323.D71CB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261004-winbond-master-spi-nor-w35t-v2-7-592f3300a70f@bootlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] mtd: spi-nor: rejecting len != 1 in Octal DTR mode breaks 2-byte SR writes
- [High] mtd: spi-nor: hardware WEL state leak on early return in spi_nor_write_sr_ll()
--

commit 101ce767bdad155741f87e7d7cf56f7779db6402
Author: Miquel Raynal <miquel.raynal@bootlin.com>

mtd: spi-nor: Fix WRSR with ODTR chips

The ODTR interface requires an even number of bytes in each section of
the operation. spi_nor_spimem_setup_op() takes care of the opcode phase,
but we have to adapt the rest of the operation ourself.

> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index cf23094021daa..381bbc13f82ff 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -791,6 +791,17 @@ static int spi_nor_write_sr_ll(struct spi_nor *nor, u8 opcode, const u8 *sr,
>  	if (nor->spimem) {
>  		struct spi_mem_op op = SPI_NOR_WRSR_OP(opcode,
>  						       nor->bouncebuf, len);
> +		if (nor->reg_proto == SNOR_PROTO_8_8_8_DTR) {
> +			if (len != 1)
> +				return -EOPNOTSUPP;

[Severity: High]
Does this erroneously reject legitimate 2-byte register writes required for
DTR-enabled chips?

Looking at spi_nor_write_sr1_and_sr2(), it passes len = 2 to
spi_nor_write_sr_ll(), which is now broken by this check.

This propagates -EOPNOTSUPP out to userspace via spi_nor_sr_unlock(), resulting
in a visible regression where Software Write Protection unlocking and flash
configuration fails for 8-8-8 DTR chips.

[Severity: High]
Does returning early here leave the Write Enable Latch (WEL) persistently active
on the flash device?

Since spi_nor_write_sr_ll() calls spi_nor_write_enable(nor) earlier in the
function, this early return happens without executing the SPI command that would
naturally clear it. Leaving the hardware write-enabled risks accidental data
corruption from stray writes.

> +
> +			/*
> +			 * We don't want to write only one byte in DTR mode. So,
> +			 * duplicate the buffer and write 2.
> +			 */
> +			op.data.nbytes = 2;
> +			nor->bouncebuf[1] = nor->bouncebuf[0];
> +		}
>  
>  		spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261004-winbond-master-spi-nor-w35t-v2-0-592f3300a70f@bootlin.com?part=7

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2026-10-04 21:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 21:31 [PATCH v2 00/17] mtd: spi-nor: winbond: Add support for the W35TxxNW family Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 01/17] mtd: spi-nor: Only switch to ODTR if the chip has a callback for it Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 02/17] mtd: spi-nor: swp: Fix SR2 initialization Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 03/17] mtd: spi-nor: Fix spacing between arguments Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 04/17] mtd: spi-nor: Fix comment indentation to clarify the intent Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 05/17] mtd: spi-nor: sfdp: Enhance a comment Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 06/17] mtd: spi-nor: Drop stale values Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 07/17] mtd: spi-nor: Fix WRSR with ODTR chips Miquel Raynal
2026-10-04 21:43   ` sashiko-bot [this message]
2026-10-04 21:31 ` [PATCH v2 08/17] mtd: spi-nor: Allow configuring the actual number of dummy cycles Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 09/17] mtd: spi-nor: Fix SWP for octal DTR chips Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 10/17] mtd: spi-nor: winbond: Prepare the introduction of W35TxxNW parts Miquel Raynal
2026-10-04 21:45   ` sashiko-bot
2026-10-13 16:22     ` Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 11/17] mtd: spi-nor: winbond: Add support for W35T64NW-C Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 12/17] mtd: spi-nor: winbond: Add support for W35T12NW-C Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 13/17] mtd: spi-nor: winbond: Add support for W35T25NW-C/E Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 14/17] mtd: spi-nor: winbond: Add support for W35T51NW-C/E Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 15/17] mtd: spi-nor: winbond: Add support for W35T01NW-C/E Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 16/17] mtd: spi-nor: winbond: Add support for W35T02NW-C/E Miquel Raynal
2026-10-04 21:31 ` [PATCH v2 17/17] mtd: spi-nor: Fix the meaning of a comment Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261004214323.D71CB1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=STLin2@winbond.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=takahiro.kuwano@infineon.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.