From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Peter Suti <peter.suti@streamunlimited.com>
Cc: u-boot@lists.denx.de,
"Radek Dostál" <radek.dostal@streamunlimited.com>,
"Tom Rini" <trini@konsulko.com>,
"Michael Trimarchi" <michael@amarulasolutions.com>,
"Mikhail Kshevetskiy" <mikhail.kshevetskiy@iopsys.eu>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Andrew Goodbody" <andrew.goodbody@linaro.org>
Subject: Re: [PATCH 2/2] cmd: mtd: fix default length calculation when offset is specified
Date: Thu, 08 Jan 2026 18:19:44 +0100 [thread overview]
Message-ID: <87tswwxbrj.fsf@bootlin.com> (raw)
In-Reply-To: <d34e03afc6c5bba074bae1684ca1f74159735210.1765892031.git.peter.suti@streamunlimited.com> (Peter Suti's message of "Tue, 16 Dec 2025 14:40:42 +0100")
On 16/12/2025 at 14:40:42 +01, Peter Suti <peter.suti@streamunlimited.com> wrote:
> When the 'mtd read' command is issued with an offset but no size (argc=1),
> the length defaults to the full partition size ('mtd->size').
>
> This calculation is incorrect because reading 'mtd->size' bytes starting
> from a non-zero offset results in a read request that extends past the
> end of the partition. This causes the MTD layer to return error -22
> (EINVAL).
>
> Fix the default length calculation to be 'mtd->size - offset' so that
> reads starting from an offset effectively read "to the end of the
> partition" rather than attempting to read out of bounds.
>
> Signed-off-by: Peter Suti <peter.suti@streamunlimited.com>
> [add {} for better readability]
> Signed-off-by: Radek Dostál <radek.dostal@streamunlimited.com>
Makes sense.
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
prev parent reply other threads:[~2026-01-08 17:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1765892031.git.peter.suti@streamunlimited.com>
2025-12-16 13:40 ` [PATCH 1/2] cmd: mtd: fix read failure on default full partition read with bad blocks Peter Suti
2025-12-20 8:39 ` Michael Nazzareno Trimarchi
2026-01-12 8:36 ` Peter Suti
2026-01-08 17:17 ` Miquel Raynal
2025-12-16 13:40 ` [PATCH 2/2] cmd: mtd: fix default length calculation when offset is specified Peter Suti
2025-12-20 8:42 ` Michael Nazzareno Trimarchi
2026-01-12 8:39 ` Peter Suti
2026-01-08 17:19 ` Miquel Raynal [this message]
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=87tswwxbrj.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=andrew.goodbody@linaro.org \
--cc=michael@amarulasolutions.com \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=peter.suti@streamunlimited.com \
--cc=radek.dostal@streamunlimited.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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