From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: "Miquel Raynal" <miquel.raynal@bootlin.com>,
linux-sunxi@lists.linux.dev, "Michael Walle" <mwalle@kernel.org>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
conor+dt@kernel.org,
"Takahiro Kuwano" <takahiro.kuwano@infineon.com>,
"Pratyush Yadav" <pratyush@kernel.org>,
devicetree@vger.kernel.org, "Richard Weinberger" <richard@nod.at>,
robh@kernel.org
Subject: Re: [PATCH v2 3/3] mtd: rawnand: sunxi: select the packed H6/H616 OOB layout
Date: Fri, 04 Sep 2026 21:47:01 +0000 [thread overview]
Message-ID: <20260904214701.EA0A31F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-submit-sunxi-nand-vendor-oob-layout-v1-v2-3-b12074f4aca7@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The free OOB layout for steps > 0 incorrectly overlaps with hardware ECC bytes, leading to uncorrectable data corruption.
- [High] Division by zero kernel panic when NAND_ECC_MAXIMIZE_STRENGTH is configured on 512-byte NAND pages.
--
commit 250f35cb46a45ae57aae72a174fbcad8b8b7a7e5
Author: James Hilliard <james.hilliard1@gmail.com>
Subject: mtd: rawnand: sunxi: select the packed H6/H616 OOB layout
This commit updates the sunxi NAND driver to support the randomized OOB
layout used by the H6/H616 controllers. It configures a separate protected
user-data length for each ECC step and allocates up to 16 bytes for step zero.
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index c1246a9268ca5..1265d900fc276 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
[ ... ]
> @@ -2111,6 +2126,10 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
> bytes -= 2;
>
> bytes -= total_user_data_sz;
> + } else if (sunxi_nand->randomized_oob) {
> + total_user_data_sz =
> + sunxi_nfc_h6_user_data_sz(nsectors);
> + bytes -= total_user_data_sz;
> } else {
> /*
> * User-data lengths are encoded in four-byte units. Reserve
[Severity: High]
This is a pre-existing issue, but I noticed a potential division by zero
kernel panic in sunxi_nand_hw_ecc_ctrl_init() when NAND_ECC_MAXIMIZE_STRENGTH
is configured on 512-byte NAND pages.
If a NAND device with a 512-byte page size is configured with the
nand-ecc-maximize property in the device tree, mtd->writesize will be 512.
This function forces ecc->size = 1024 and calculates:
nsectors = mtd->writesize / ecc->size;
This resolves to 0, and a few lines down the code executes:
bytes /= nsectors;
Would it be safer to gracefully fail (e.g., returning -EINVAL) instead of
allowing a fatal division by zero during device probe?
[Severity: Critical]
This is also a pre-existing issue, but I wanted to ask about the free OOB
layout defined in sunxi_nand_ooblayout_free(), which isn't modified by
this patch.
For sections greater than 0, the driver does:
oobregion->offset = sunxi_get_ecc_offset(sunxi_nand, ecc, section);
oobregion->length = user_data_sz;
This appears to incorrectly overlap with hardware ECC bytes, defining the MTD
free region exactly over the hardware ECC bytes instead of the user data
bytes.
Could this lead to unrecoverable data corruption if standard filesystems
(like JFFS2 or UBIFS) write metadata to the free OOB area, unknowingly
overwriting the ECC codes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-submit-sunxi-nand-vendor-oob-layout-v1-v2-0-b12074f4aca7@gmail.com?part=3
prev parent reply other threads:[~2026-09-04 21:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 21:22 [PATCH v2 0/3] mtd: rawnand: sunxi: support the Allwinner randomized OOB format James Hilliard
2026-09-04 21:22 ` [PATCH v2 1/3] dt-bindings: mtd: sunxi: Add randomized OOB flag James Hilliard
2026-09-04 21:22 ` [PATCH v2 2/3] mtd: rawnand: sunxi: support randomized OOB formats James Hilliard
2026-09-08 15:51 ` Miquel Raynal
2026-09-04 21:22 ` [PATCH v2 3/3] mtd: rawnand: sunxi: select the packed H6/H616 OOB layout James Hilliard
2026-09-04 21:47 ` sashiko-bot [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=20260904214701.EA0A31F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=james.hilliard1@gmail.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=takahiro.kuwano@infineon.com \
--cc=vigneshr@ti.com \
/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