Re: [PATCH] mtd: core: skip empty read and write requests
From: Miquel Raynal
Date: Wed Nov 18 2026 - 05:43:29 EST
On 04/11/2026 at 22:03:38 -07, James Hilliard <james.hilliard1@xxxxxxxxx> wrote:
> Converting mtd_read() and mtd_write() to wrappers around the OOB helpers
> removed their zero-length checks. Neither mtd_read_oob() nor
> mtd_write_oob() stops an empty request from reaching the driver.
>
Yes
> For example, the raw NAND read paths select a target and can read a page
> or its OOB area before checking the remaining length. An empty request
> at the end of the device can therefore select a target past the last
> available one.
No, there is a guard against that.
An empty request at the end of the device can therefore compute a die
index past the last available one and hit the WARN_ON() in
nand_select_target().
> Return success from the common helpers when both lengths are zero,
Ok
> after mtd_check_oob_ops() has normalized lengths for absent buffers.
This is opaque to me, just drop.
> Keep the existing range, write-protection and operation-support checks,
> and clear the per-request read statistics before returning. Both return
> lengths have already been initialized to zero.
>
> Fixes: 2431c4f5b46c ("mtd: Implement mtd_{read,write}() as wrappers around mtd_{read,write}_oob()")
> Cc: stable@xxxxxxxxxxxxxxx
> Link: https://lore.kernel.org/r/sashiko-outbox-198544@xxxxxxxxxx
> Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
Thanks,
Miquèl