From: Peter Suti <peter.suti@streamunlimited.com>
To: u-boot@lists.denx.de
Cc: Peter Suti <peter.suti@streamunlimited.com>
Subject: [PATCH 0/3] cmd: mtd: fix default read behavior and boundary checks
Date: Mon, 12 Jan 2026 10:09:25 +0100 [thread overview]
Message-ID: <cover.1768208271.git.peter.suti@streamunlimited.com> (raw)
This series addresses two issues in the 'mtd read' command regarding how
default read lengths are calculated and handled when no size argument is
provided.
The first patch fixes a failure when reading a full NAND partition that
contains bad blocks. Currently, skipping bad blocks increments the physical
offset without adjusting the remaining byte count, causing the read to
attempt accessing past the end of the partition. The fix ensures that
default full-partition reads are truncated gracefully at the physical
boundary rather than returning an error.
This behaviour is similar to the raw `nand` command which adjusts the size
of the read with adjust_size_for_badblocks().
The second patch fixes the default length calculation when a starting
offset is specified. Previously, the command defaulted to reading the
entire partition size ('mtd->size') starting from the offset, which
inevitably exceeds the partition bounds. The fix adjusts the default length
to 'mtd->size - offset'.
Changes in v2:
- Separate commit for additional debug logs for bad blocks.
- Return error when start_off >= mtd->size.
- Resent to fix threading issues from v1.
Link to V1: https://lore.kernel.org/u-boot/cover.1765891388.git.peter.suti@streamunlimited.com/T/#u
Peter Suti (3):
cmd: mtd: add logs when bad blocks are encountered
cmd: mtd: fix read failure on default full partition read with bad
blocks
cmd: mtd: fix default length calculation when offset is specified
cmd/mtd.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
--
2.43.0
next reply other threads:[~2026-01-12 13:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 9:09 Peter Suti [this message]
2026-01-12 9:09 ` [PATCH v2 0/3] cmd: mtd: fix default read behavior and boundary checks Peter Suti
2026-01-12 9:09 ` [PATCH v2 1/3] cmd: mtd: add logs when bad blocks are encountered Peter Suti
2026-01-12 13:35 ` Quentin Schulz
2026-01-12 9:09 ` [PATCH v2 2/3] cmd: mtd: fix read failure on default full partition read with bad blocks Peter Suti
2026-01-12 9:09 ` [PATCH v2 3/3] cmd: mtd: fix default length calculation when offset is specified Peter Suti
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=cover.1768208271.git.peter.suti@streamunlimited.com \
--to=peter.suti@streamunlimited.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox