linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: parsers: bcm47xxpart: Fix halfblock reads
@ 2022-10-18  9:11 Linus Walleij
  2022-10-18  9:45 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2022-10-18  9:11 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, Linus Walleij, stable, Rafał Miłecki,
	Florian Fainelli

There is some code in the parser that tries to read 0x8000
bytes into a block to "read in the middle" of the block. Well
that only works if the block is also 0x10000 bytes all the time,
else we get these parse errors as we reach the end of the flash:

spi-nor spi0.0: mx25l1606e (2048 Kbytes)
mtd_read error while parsing (offset: 0x200000): -22
mtd_read error while parsing (offset: 0x201000): -22
(...)

Fix the code to do what I think was intended.

Cc: stable@vger.kernel.org
Fixes: f0501e81fbaa ("mtd: bcm47xxpart: alternative MAGIC for board_data partition")
Cc: Rafał Miłecki <zajec5@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Add some fixes and stable tags.
---
 drivers/mtd/parsers/bcm47xxpart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/parsers/bcm47xxpart.c b/drivers/mtd/parsers/bcm47xxpart.c
index 50fcf4c2174b..13daf9bffd08 100644
--- a/drivers/mtd/parsers/bcm47xxpart.c
+++ b/drivers/mtd/parsers/bcm47xxpart.c
@@ -233,11 +233,11 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 		}
 
 		/* Read middle of the block */
-		err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read,
+		err = mtd_read(master, offset + (blocksize / 2), 0x4, &bytes_read,
 			       (uint8_t *)buf);
 		if (err && !mtd_is_bitflip(err)) {
 			pr_err("mtd_read error while parsing (offset: 0x%X): %d\n",
-			       offset + 0x8000, err);
+			       offset + (blocksize / 2), err);
 			continue;
 		}
 
-- 
2.34.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mtd: parsers: bcm47xxpart: Fix halfblock reads
  2022-10-18  9:11 [PATCH v2] mtd: parsers: bcm47xxpart: Fix halfblock reads Linus Walleij
@ 2022-10-18  9:45 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-10-18  9:45 UTC (permalink / raw)
  To: Linus Walleij, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, stable, Rafał Miłecki, Florian Fainelli

On Tue, 2022-10-18 at 09:11:29 UTC, Linus Walleij wrote:
> There is some code in the parser that tries to read 0x8000
> bytes into a block to "read in the middle" of the block. Well
> that only works if the block is also 0x10000 bytes all the time,
> else we get these parse errors as we reach the end of the flash:
> 
> spi-nor spi0.0: mx25l1606e (2048 Kbytes)
> mtd_read error while parsing (offset: 0x200000): -22
> mtd_read error while parsing (offset: 0x201000): -22
> (...)
> 
> Fix the code to do what I think was intended.
> 
> Cc: stable@vger.kernel.org
> Fixes: f0501e81fbaa ("mtd: bcm47xxpart: alternative MAGIC for board_data partition")
> Cc: Rafał Miłecki <zajec5@gmail.com>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-18  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18  9:11 [PATCH v2] mtd: parsers: bcm47xxpart: Fix halfblock reads Linus Walleij
2022-10-18  9:45 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).