[PATCH 0/2] mtd: spinand: fix nand-no-ecc-engine support

Nuno Sá posted 2 patches 3 weeks, 4 days ago
drivers/mtd/nand/ecc.c      |  7 +++++++
drivers/mtd/nand/spi/core.c | 21 ++++++++++++---------
include/linux/mtd/nand.h    |  2 ++
3 files changed, 21 insertions(+), 9 deletions(-)
[PATCH 0/2] mtd: spinand: fix nand-no-ecc-engine support
Posted by Nuno Sá 3 weeks, 4 days ago
Setting "nand-no-ecc-engine" in DT currently oopses at probe: SPI-NAND
dereferences nand->ecc.engine unconditionally to test for a pipelined
engine, but nanddev_get_ecc_engine() leaves that pointer NULL when no
engine is requested. Patch 1 adds a nand_ecc_is_pipelined() helper to
the NAND core that folds in the NULL check, and uses it at the three
affected sites.

With the oops out of the way the device probes, but registers an MTD
advertising zero available OOB bytes. That makes every MTD_OPS_AUTO_OOB
access fail with -EINVAL, and JFFS2 refuse to mount. Patch 2 installs
the fallback ooblayout and counts the free bytes unconditionally.

---
Nuno Sá (2):
      mtd: spinand: fix NULL pointer dereference with no ECC engine
      mtd: spinand: fix zero oobavail when no ECC engine is used

 drivers/mtd/nand/ecc.c      |  7 +++++++
 drivers/mtd/nand/spi/core.c | 21 ++++++++++++---------
 include/linux/mtd/nand.h    |  2 ++
 3 files changed, 21 insertions(+), 9 deletions(-)
---
base-commit: 15a3cbce32994141252bb4ecfe3ff3a5d22d0b4f
change-id: 20260831-mtd-nand-no-ecc-fixes-6341fbbeb059
--

Thanks!
- Nuno Sá

Re: [PATCH 0/2] mtd: spinand: fix nand-no-ecc-engine support
Posted by Miquel Raynal 3 weeks ago
On Mon, 31 Aug 2026 16:07:16 +0100, Nuno Sá wrote:
> Setting "nand-no-ecc-engine" in DT currently oopses at probe: SPI-NAND
> dereferences nand->ecc.engine unconditionally to test for a pipelined
> engine, but nanddev_get_ecc_engine() leaves that pointer NULL when no
> engine is requested. Patch 1 adds a nand_ecc_is_pipelined() helper to
> the NAND core that folds in the NULL check, and uses it at the three
> affected sites.
> 
> [...]

Applied to mtd/fixes, thanks!

[1/2] mtd: spinand: fix NULL pointer dereference with no ECC engine
      commit: ea765ae1efb2665da8981eba82b8a72e314af854
[2/2] mtd: spinand: fix zero oobavail when no ECC engine is used
      commit: a039958f2b95e6cc7f0e44d40298d17f1c0851c0

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl